+ 1
Output of following expression of C programme
int i=8,j=5; float x=0.005,y=-0.01; char c='c',d='d'; Expression is (3×i-2×j)+(i%2*d-c)
7 Respostas
+ 6
Well, I just tested it in Code Playground, the result evaluates to -85, here I try to break the order of operation of the expression, I hope it is clear enough to understand : )
(3 * i - 2 * j) = (3 * 8 - 2 * 5) = (24 - 10) = 14
(i % 2 * d - c) = ((8 % 2) * 'd' - 'c') = (0 * 100 - 99) = -99
14 + (-99) = (14 - 99) = -85
Hth, cmiiw
+ 4
Have you tried to execute it and get the answer by yourself?...
Then, if you don't get it, you can ask others to explain...
+ 4
it's simple algebraic operations , you just need to know one thing apart from that : whenever you include a character in a arithmetic operation then the number that would be used for it would be it's ASCII code.
+ 3
my answer was also -85. I just wanted to confirm cause I wasn't sure. thanks a lot .
+ 1
why would I ask a question if I haven't done it myself
+ 1
Please also explain the result
0
the result is 0.1199