Thursday, May 3, 2018

POINTER TO FUNCTION IN C

Here is a simple code to show how to use pointers to function in C.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Sample Program Output

Program Listing

pointers.c

/* May 2, 2018    */
/* Barangay Alijis, Bacolod City Negros Occidental Philippines */
/* Dev C++ */
/* Author : Mr. Jake R. Pomperada, MAED-IT */


#include <stdio.h>
#include <conio.h>

void Add(int,int);
void Product(int,int);


int main() 
{
     int a=0,b=0;
     
     printf("======  POINTER TO FUNCTION IN C =====");
     printf("\n\n");
     printf("Created By Mr. Jake R. Pomperada, MAED-IT");
     printf("\n\n");
     printf("Give Two Numbers : ");
     scanf("%d%d",&a,&b);
           
     void (*pf)(int,int);
     
     pf = Add;
     
     (*pf)(a,b);
     
     pf = Product;
     
     (*pf)(a,b);
     
     
    printf("\n\n\n\n");
    printf("===== END OF PROGRAM =====");
    printf("\n\n");
    system("pause");
}
  

 void Add(int x,int y)
 {
      int c=0;
      c = x + y;
      printf("\n\n");
      printf("The sum is %d.",c);
}
         
 void Product(int x,int y)
 {
      int d=0;
      d = x * y;
      printf("\n\n");
      printf("The product is %d.",d);
}



No comments:

Post a Comment