C program to swap two numbers with And without using third variable, Swapping means to interchange of two numbers. In this program to Swapping two numbers without using third variables.
Swapping of two numbers in C program codes
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b;
clrscr();
printf("\n Enter the two values of a And b ");
scanf("%d%d",&a,&b);
a = a + b;
b = a - b;
a = a - b;
printf("\n After Swapping a = %d\t, b = %d",a,b);
getch();
}
Output:-

Swapping of two numbers in C program codes
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b;
clrscr();
printf("\n Enter the two values of a And b ");
scanf("%d%d",&a,&b);
a = a + b;
b = a - b;
a = a - b;
printf("\n After Swapping a = %d\t, b = %d",a,b);
getch();
}
Output:-
