/* Answer on Question#43023 - Subject - Programming, C++ */
#include <stdio.h>
#include <stdlib.h>
void (*p) ( int, int ); /* pointer to function */
void swap( int x, int y) /* swapping two integer function */
{
int temp = y; /*temp var*/
y = x; /* swapping */
x = temp;
printf("Integers after awapping...\nx= %d\ny= %d\n",x,y);
}
int main() /* main function*/
{
int x,y;
printf("x= "); /* user's input of integers */
scanf("%d",&x);
printf("y= ");
scanf("%d",&y);
p = &swap; /* pointer to swap */
p(x,y); /* call the function */
system("pause");
return 0;
}
Comments
Leave a comment