Swap two number without using third variable in c programming language.
For Example:
INPUT:
a = 10;
b = 20;
OUTPUT:
a = 20;
b = 10
// write a c program to swap two numbers without using third variable.
#include <stdio.h>
int main()
{
int a, b;
printf("Enter the value of a : ");
scanf("%d", &a);
printf("Enter the value of b : ");
scanf("%d", &b);
a = a + b;
b = a - b;
a = a - b;
printf("The value of a is %d and b is %d", a, b);
return 0;
}
Comments
Oops!