int main(void)
{
  int a = 10;                         /* Initial value for a */
  int b = 5;                          /* Initial value for b */
  int result = 0;                     /* Storage for results */
  int (*pf)(int, int) = sum;          /* Pointer to function */

  /* Passing a pointer to a function */
  result = any_function(pf, a, b);

  printf("\nresult = %d", result );

  /* Passing the address of a function      */
  result = any_function(product,a, b);

   printf("\nresult = %d", result );

  printf("\nresult = %d\n", any_function(difference, a, b));
  return 0;
}
Beispiel #2
0
int main(void)
{
  int a = 10;                         // Initial value for a
  int b = 5;                          // Initial value for b
  int result = 0;                     // Storage for results
  int (*pf)(int, int) = sum;          // Pointer to function

  // Passing a pointer to a function
  result = any_function(pf, a, b); 

  printf("result = %2d\n", result );

  // Passing the address of a function
  result = any_function(product,a, b);

  printf("result = %2d\n", result );

  printf("result = %2d\n", any_function(difference, a, b));
  return 0;
}
Beispiel #3
0
int main(void)
{
	int a = 10;
	int b =  5;
	int result = 0;

	int (*pf)(int,int) = sum;

	result = any_function(pf,a,b);	

	printf("\nResult = %d", result);

	result = any_function(product,a,b);

	printf("\nResult = %d", result);
	
	printf("\nResult = %d\n", any_function(difference,a,b));

	return 0;
}