64 713
Assignments Done
99,4%
Successfully Done
In September 2018

Answer to Question #43023 in C++ for Syed Talha Shah

Question #43023
Write a program to make the pointer to the function for swapping two integers.
Expert's answer
/* 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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions