How to swap 3 numbers without using 4th variable?

Answers were Sorted based on User's Feedback



How to swap 3 numbers without using 4th variable?..

Answer / sundar

a=a+b+c
b=a-(b+c)
c=a-(b+c)
a=a-(b+c)

Is This Answer Correct ?    89 Yes 13 No

How to swap 3 numbers without using 4th variable?..

Answer / pallavi dhanopiya

a=a*b*c;
b=a/b/c;
c=a/b/c;
a=a/b/c;

Is This Answer Correct ?    12 Yes 3 No

How to swap 3 numbers without using 4th variable?..

Answer / 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

How to swap 3 numbers without using 4th variable?..

Answer / mujamil

how to swap of 4number

Is This Answer Correct ?    3 Yes 1 No

How to swap 3 numbers without using 4th variable?..

Answer / pavan

a=(a+b+c)-(b=a)-(c=b)

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C Interview Questions

What is the difference between c &c++?

0 Answers  


Here is alphabets : abcdefgh 1) how to reverse. as hgfedcba 2) after reversal, how to group them in a pair hg fe dc ba.

2 Answers  


What is the equivalent code of the following statement in WHILE LOOP format?

0 Answers  


What are integer variable, floating-point variable and character variable?

0 Answers  


Can a file other than a .h file be included with #include?

0 Answers   Aspire, Infogain,






What are keywords in c with examples?

0 Answers  


Is a house a shell structure?

0 Answers  


Is c an object oriented programming language?

1 Answers  


What is the purpose of macro in C language?

0 Answers   Fidelity,


What is malloc and calloc?

0 Answers  


Difference between strcpy() and memcpy() function?

0 Answers  


What is sizeof array in c?

0 Answers  


Categories