Program to show swap of two no's without using third variable.

C Programming Language / Overview of C Language

1141

Program:

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
 
	printf("enter value for a & b: \n");
	scanf("%d%d",&a,&b);
	printf("Before swapping the value of a=%d & b=%d \n",a,b);
	a=a+b;
	b=a-b;
	a=a-b;
	printf("After swapping the value of a=%d & b=%d \n",a,b);
 
}

Output:

enter value for a & b:
2  3
Before swapping the value of a=2 & b=3
After swapping the value of a=3 & b=2
Press any key to continue . . .

Explanation:

Program to show swap of two no’s without using the third variable.

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.