C program to pass function as an argument to a function
Given two integer values and we have to pass them to function 1, that will return the sum and then we have to pass function 1 as an argument to the function 2, which will print the sum in C.
Note: When, we will pass the fun_1() to the fun_2(), it will be treated as an integer values because fun_2() is taking an argument of integer type. So, first of all fun_1() will be executed and return the sum of the given parameters and sum will be passed to the fun_2() which will be processed.
Consider the given functions,
1) function 1 (fun_1)
int fun_1(int a , int b)
Function is taking two integer arguments and returning their sum.
2) function 2 (fun_2)
int fun_2(int temp)
printf("\nThe value of temp is : %d",temp);
Function is taking an integer value and printing it.
Function calling seems to like ‘passing function to a function as an argument’