To swap the values of two variables using C


Levels of difficulty: / perform operation:

C program to swap the values of two variables.

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	int a,b,c;
	clrscr();
	printf("\nENTER TWO NUMBERS FOR a AND b:\n");
	scanf("%d %d",&a,&b);
	printf("\nBEFORE SWAPING THE VALUE OF a=%d AND b=%d",a,b);
	c=a;
	a=b;
	b=c;
	printf("\nAFTER SWAPING THE VALUE OF a=%d AND b=%d",a,b);
	getch();
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview