KodeGod.com

063. Write a program to accept two numbers from user and swap their values using call by reference method in C language

#include<stdio.h>
#include<conio.h>  
#include<process.h>

swap(int *x ,int *y)
{
	int temp;
	temp=*x;
	*x=*y;
	*y=temp;
}
main()
{
	int a,b;
	clrscr();
	printf("Enter numbers : ");
	scanf("%d%d",&a,&b);
        printf("\nBefore Swapping a = %d, b = %d\n",a,b);
	swap(&a,&b);
	printf("\nAfter  Swapping a = %d, b = %d\n",a,b);
	getch();
}