How to swap 3 numbers without using 4th variable?

Answer Posted / ilana

The target is a<-b b<-c c<- a
------------------------------------
a = a+b+c ; // a+b+c b c
c = c+b; // a+b+c b b+c
b = c-b; // a+b+c c b+c
c = a-c; // a+b+c c a
a = a-(b+c) // b c a

Is This Answer Correct ?    12 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

pierrot's divisor program using c or c++ code

1730


i got 75% in all semester am i eligible for your company

1735


What was noalias and what ever happened to it?

591


List some basic data types in c?

557


What is file in c language?

574






What is the difference between class and object in c?

581


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

1886


What is a floating point in c?

600


What is the meaning of ?

612


What is union in c?

634


What is the size of a union variable?

598


Explain what is the difference between #include and #include 'file' ?

583


Write a C program in Fibonacci series.

633


What are nested functions in c?

564


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

668