/* Program to swap
two numbers using call by reference */
#include<stdio.h>
#include<conio.h>
void
swapr(int *x,int *y);
void
main()
{
int a=10,b=20;
clrscr();
swapr(&a,&b);
printf("\na=%d and b=%d",a,b);
getch();
}
void
swapr(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
printf("\nx=%d and y=%d",*x,*y);
}
OUTPUT
x=20
and y=10
a=20
and b=10
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.