In this, we passed addresses instead of values and function pointers accept addresses and pointing to the actual values.
e.g:#include<iostream.h> #include<conio.h> void swap(int *,int *); void main() { int a,b; clrscr(); cout<<"Enter values for a "; cin>>a; cout<<"Enter values for b "; cin>>b; swap(&a,&b); cout<<"After swap a = "<<a<<" and b = "<<b; getch(); } void swap(int *p,int *q) { int temp; temp=*p; *p=*q; *q=temp; cout<<"After swap a = "<<*p<<" and b = "<<*q; }O/P
Enter value for a 4 Enter value for b 5 After swap a = 5 and b =4