C program to swap two numbers without using third variable

C program to swap two variable without using third variable

    1.  #include<stdio.h>
    2. int main()
    3. {
    4.   int a = 10;
    5.   int b = 20;
    6.   printf("Before swap a=%d b=%d\n",a,b);
    7.     a = a+b;
    8.     b = a-b;
    9.     a = a-b;
    10.   printf("\nAfter swap a=%d b=%d\n",a,b);
    11.   return 0;
    12. }


Post a Comment

0 Comments