A program to swap the content of two integer variable using call by reference.
A program to swap the content of two integer variable using call by reference.
Codes
/*A program to swap the content of two integer variable using call by reference*/
/*Programed by Jitendra Kr Yadav
10116
2Apr,2011*/
#include<stdio.h>
#include<conio.h>
void swap(int*, int *);
main()
{
inta,b;
printf(“Enter the value of a and b:\n”);
scanf(“%d%d”,&a,&b);
swap(&a,&b);
printf(“a = %d and b = %d”,a,b);
printf(“Press any key to continue…”);
getch();
}
void swap(int*x,int*y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
Output
Enter the value of ‘a’ and ‘b’:
5
2
a = 2 and b = 5
Press any key to continue…
Comments (3)