Saturday, July 13, 2019

Swapping The Number WithOut Using 3rd variable.

Swapping The Number WithOut Using 3rd variable



//Swapping Without Using 3rd Variable.

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b;
clrscr();
printf("Enter The Value Of A and b :-");
scanf("%d%d",&a,&b);

//Logic Of Swapping without using 3rd variable.

a=a+b;
b=a-b;
a=a-b;

printf("After Swaping %d %d",a,b);
getch();
}

Output:



EmoticonEmoticon