Swap two numbers using third variable in C Language

Swap two numbers using third variable in C Language

Write a program in C Language to Swap two numbers using third variable.

/*    Swap two numbers using third variable    */
#include<stdio.h>
int main()
{
	int a;
	int b;
	int c;

	printf("Type value of A : ");
	scanf("%i",&a);
	printf("\nType value of b : ");
	scanf("%i",&b);
	c=a;
	a=b;
	b=c;
	printf("A : %i",a);
	printf("\nb : %i",b);
	return 0;
}

 

Leave a Reply

Close Menu