Swapping of Two Numbers in C Without usingTemporary variable

Swapping of Two Numbers in C without using Temporary variables: 

First, see the: Swapping of  two numbers in C

Swapping of Two number program in C without using Temporary variables:
int main()
 int a;
 int b;
 printf("Type value of A = ");
 printf("\nType value of B = ");
  a = a + b;
  b = a - b;
  a = a - b ;

 printf("A = %i",a);
 printf("\nB = %i",b);
 return 0;
Type value of A = 5
Type value of B = 2
A = 2
B = 5
  • Two integers a, b is declared of Type int.
  • The values of a, b are taken from the keyboard given by the user.
  • Now the value of both the values is added and stored in "a". Now the new "a" value the "b" value subtracted and value is stored in "b". i.e ( 7 - 2 = 5) .
  • Now "b" value is"5" and again we subtracting "a - b" where "b" value is "5". And the result of "a - b" i.e( 7 - 5 = 2) is stored in "a".
  • And last Printf Prints the value of “a” and “b”.
See also:

Our Services

Search This Blog

  • ()
Powered by Blogger.

Alphabet Pattern (or) Character Pattern21 Program in C

Write "C"  Program to print below Alphabet Pattern21 (or) Character Pattern21: To underst...

Blog Archive