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 are actual arguments?

0 Answers  


What is use of pointer?

0 Answers  


main() { printf("hello%d",print("QUARK test?")); }

5 Answers  


what is the maximum limit of row and column of a matrix in c programming. in linux .

4 Answers   NIIT,


How do you initialize pointer variables?

0 Answers  






write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a<b,printb.find the sum digits of that number & then print.if a==b multiply 10 with a & add 20 with b store in c and then print

0 Answers  


What are multibyte characters?

0 Answers  


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database

2 Answers   TCS, Unisys, Webyog,


What is the 'named constructor idiom'?

0 Answers  


How a string is stored in c?

0 Answers  


What are the back slash character constants or escape sequence charactersavailable in c?

0 Answers  


what value is returned to operating system after program execution?

0 Answers  


Categories