Interchange two values without Third Variable

Interchange 2 values without using third Variable or Temp Variable  in C Language.


[c]

#include<stdio.h>
int main(){

int a=5,b=10;

a=b+a;
b=a-b;
a=a-b;
printf("a= %d b= %d",a,b);

}

[/c]

Share

About the Author

Akash Padhiyar

Visit Website

One Comment

  1. Here another type is there to find swapping of two numbers without using third variable…..
    that is

    #include
    #include
    int main(){

    int a=5,b=10;
    clrscr();
    a=a+b-(b=a);
    printf(“a=%d b=%d”,a,b);
    getch();
    }

Leave a Comment

Your email address will not be published. Required fields are marked *

*

Time limit is exhausted. Please reload CAPTCHA.