An Algorithm, Flowchart and C-Code for swapping the 2 numbers ( without using third variable )

  1. START
  2. Input First number as A
  3. Input Second number as B.
  4. Assign A = A + B
  5. Assign B = A – B
  6. Assign A = A – B
  7. Print Value of A and B.
  8. END

Flowchart for swapping the 2 numbers ( without using third variable )

C-Code for swapping the 2 numbers ( without using third variable )

#include<stdio.h>
void main()
{
int A,B;
printf("Enter first number as A :");
scanf("%d",&A);
printf("Enter second number as B : ");
scanf("%d",&B);
A=A+B;
B=A-B;
A=A-B;
printf("After swapping the value of A is %d and B=%d ",A,B);
}