Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

#include int main() { a=5; b=10; a=a+b-(b=a); printf("\na= %d b= %d",a,b); } this program is swapping of two variables... how does it work???

OpenStudy (anonymous):

look at the math. a=5 b=10 then, the math does: a=(5)+(10)-(10-5)=10 a->b=10

OpenStudy (anonymous):

working- first your 'a' value will be stored in 'b' as yu had mention b=a which is assignment operator.....then a=a+b-(b=a) which makes 'a' value assigned with 'b' tracing- a=5 b=10 a=a+b-(b=a) a=5+10-(b=5) a=15-5 a=10 hence a=10 and b=5

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!