Thursday, February 27, 2014

Program to swap value using function call by refference

#include<stdio.h>
#include<conio.h>
int sa(int* , int*);
main()
{
int a,b;
printf("Enter A = ");
scanf("%d", &a);
printf("Enter B = ");
scanf("%d",&b);
printf("\nBefore change A = %d and  B= %d\n",a,b);
sa(&a,&b);
printf("After Change A = %d and B = %d\n",a,b);
getch();

}
int sa(int*x, int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}

No comments:

Post a Comment