Question: is there some one who can help me with some complex math Expressions in 'C' programming.(details given below) please explain how the compiler calculates the following expressions and which variable get what value\n\n1...assume x=1 i=2 j=3 k=4   \nx-=k*=j/=i%=5;   (please explain how this works)\n\n2... x=5 i=4 j=3 k=2\nx*=1 + (i%= 1+(j/=-1+ ++k)\n\n3....i=j=10;\ni%=j=(j=5)%(i=3);\n\nthanks

Answer: in C the evaluation for an expression goes like this:\nEvaluate the right part of expression and then the left one\nand i=5 returns 5\nso:\n1. x-=k*=j/=i%=5;\n - i%=5 -> 2 and i=2\n - j/=i%=5 -> j/=2 -> 1 and j = 1\n - k*=j/=i%=5 -> k*= 1 -> 4\n - x-=k*=j/=i%=5 -> x-=4 -> -3 and x= -3\n2.x*=1 + (i%= 1+(j/=-1+ ++k)\n - ++k - > 3 and k=3 \n - j/=-1+ ++k -> j/=-1 + 3 -> j/= 2 -> 1\n -... i%= 1+(j/=-1+ ++k) -> 0\n - x*=1 + (i%= 1+(j/=-1+ ++k)) -> x*= 1+0\n - x = 5\n3.i%=j=(j=5)%(i=3)\n - i=3 -> 3 and i become 3\n - j=5 -> same\n - (j=5)%(i=3) 0 -> 2\n - j=(j=5)%(i=3) -> j=2 -> 2 and j become 2\n - i%=j=(j=5)%(i=3) -> i%= 2 -> i = 3 % 2 = 1
This question from the Yahoo Q&A forum is categorized in the topic: Business & Finance