"Call by Reference"
/*Program to show "Call by Reference"*/#include <stdio.h>
#include <conio.h>
void swap(int *x, int *y)
{
int z;
z = *x;
*x = *y;
*y = z;
printf("\n Swapped values are a = %d and b = %d", *x, *y);
}
int main (int,int)
{
int a = 10, b = 20;
printf("Original values are a = %d and b = %d", a, b);
swap(&a, &b);
printf("\n The values after swap are a = %d and b = %d", a, b);
}
Expected Output:
Original values are a = 10 and b = 20
Swapped values are a = 20 and b = 10
The values after swap are a = 10 and b = 20