#include <iostream.h>
#include <conio.h>
void swap2 (int*i, int*j); // Function prototype
void main( )
{
int a = 5, b =25 ;
swap2 (&a, &b); // Call by passing addresses of variables
cout<<"\n a = "<<a<<"\t b = "<<b;
getch( );
}
void swap2 (int *x, int *y) // Function definition
{
int temp;
// To interchange 2 numbers
temp = *x;
*x = *y;
*y = temp ;
}
0 comments:
Post a Comment