Solved programming problem

How to Swap Two Value Without using 3rd Variable in C.

Source code

#include<stdio.h>

int main()

{

    int a,b;

    printf("Please Enter Two Value: ");

    scanf("%d %d",&a,&b);

 

   /// swapping

    a = a+b;

    b = a-b;

    a = a-b;

    printf("
1st Value: %d
2nd Value: %d
",a,b);

    return 0;

}

Output

Please Enter Two Value: 5 6

1st Value: 5

2nd Value: 6

Join the discussion

Add your comment