Learn C ProgrammingLearn ProgrammingPrograms On More On FunctionsResources

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

By September 18, 2012 September 5th, 2018 No Comments
#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();
}


Leave a Reply

DEMO01