Question

The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO: 1) Add the typedef here: 5// TODO: 2) Modif

Please in C Language

Thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
typedef void (*fun_ptr)(void);
void temp(void);

void repeat(int times ,fun_ptr func)
{
for(int k=0;k<times;++k)
{
(*func)();
}
}
void test(void)
{
printf("Test!\n");
}
int main() {
repeat(10,&test);

repeat(10,&temp);

return 0;
}
void temp(void)
{
printf("My function\n");
}

The output is

Test! Test! Test! Test! Test! Test! Test! Test! Test! Test! My function My function My function My function My function My fu

Do give a thumbs up

Add a comment
Know the answer?
Add Answer to:
Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Topics: Arrays in C. For this assignment, you will write a C program that uses its...

    Topics: Arrays in C. For this assignment, you will write a C program that uses its first command line parameter to compute and display a histogram of characters that occur in it. Requirements: Your program must compile and run correctly using the gcc compiler on ale. You must write the corresponding function definitions for the following function prototypes: // set all elements of the histogram to zero void init_histogram(int histo[]); // construct the histogram from string void cons_histogram(char string[], int...

  • Given the incomplete program below, write two functions, one called integer and another called decimal. You...

    Given the incomplete program below, write two functions, one called integer and another called decimal. You can use following incomplete program. Your assignment is to supply the necessary missing code: #include #include using namespace std; int integer (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER (A DOUBLE) //WRITE HERE THE CODE TO EXTRACT THE INTEGER AND RETURN IT } double decimal (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER //WRITE HERE THE CODE TO EXTRACT THE DECIMAL PORTION,...

  • Hi, this program is in C. Can you a pass by pointer in this program. Thanks. #include //function ...

    Hi, this program is in C. Can you a pass by pointer in this program. Thanks. #include //function declaration/prototype here int main(int argc, char * argv[]) { int num1, num2;    printf("Please enter two integers (separated by ,):\n"); scanf("%d,%d", &num1, &num2); //enter two integers separated by a comma (,)    printf("num1 stores: %d\n", num1); printf("num2 stores: %d\n", num2);    /*make a function call to make sure the followings are true after we call the function (1) variable num1 stores the larger value after...

  • The following C++  code contains an incomplete program that should be able to calculate the distance between...

    The following C++  code contains an incomplete program that should be able to calculate the distance between a series of geocoded locations. Two parts of the program need to be completed: 1. The portion of the main() function that calculates the distances between each of the hard-coded 5 locations, and stores it in a two-dimensional array declared as distances. 2. A portion of the calculateDistanceBetweenLocations(l1, l2) function; omitted code spaces are designed with a // TODO: comment. The code is properly...

  • Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU...

    Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...

  • // P13_2.cpp - This program adds money of two different people #include<iostream> #include<cstdlib> using namespace std;...

    // P13_2.cpp - This program adds money of two different people #include<iostream> #include<cstdlib> using namespace std; class AltMoney {     public:         AltMoney();         AltMoney(int d, int c);         friend void add(AltMoney m1, AltMoney m2, AltMoney& sum);         void display_money( );     private:         int dollars;         int cents; }; void read_money(int& d, int& c); int main( ) {      int d, c;      AltMoney m1, m2, sum;      sum = AltMoney(0,0);      read_money(d, c);      m1 = AltMoney(d,c);      cout...

  • Please fill in this code to reverse a linked list: (written in C/C++) #include #include #include...

    Please fill in this code to reverse a linked list: (written in C/C++) #include #include #include using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list */ void...

  • I need a c++ code please. 32. Program. Write a program that creates an integer constant...

    I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...

  • C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your...

    C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your code in the source code where the comment “// your code” locates. After you finish the implementation, please also provide the output of your program. #include <iostream> using namespace std; class Shape { protected: // your code public: void setWidth (int w) { // your code } void setHeight (int h) { // your code } }; class Rectangle: public Shape { public: int...

  • Please use C++ and include source code and a picture of program output. You are required...

    Please use C++ and include source code and a picture of program output. You are required to write a C++ program that interactively reads three integers, adds the numbers, and prints the result. 1- The program should use a class and an object. 2- The program can use a public function such as int FindSum (int , int y, int z) to calculate the sum of the numbers. 3- The main function should read the numbers and passes them to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT