![]() |
doubt
Code: c++
|
Re: doubt
Run it and see what is the ouput and if you cannot justify it ask us why the output is OK/NOT OK
|
Re: doubt
as per my logic the answer is NOT OK...
because see the line (num!=(num=--num))?cout<<"OK":cout<<"NOT OK"; is a ternary operator and the words num=--num means that the num value is decreased by one and it is assigned to num so now the new value of num is 109 and the latter set of staments compares 109 with 109 [ since we know that -- operator decreases it by one so the answer is "not ok" if u need more clear explanation i m ready to explain.. hav a gud day.. |
Re: doubt
I agree with shabbir...
|
Re: doubt
The output is undefined because you modify the same variable twice in the same statement.
So the output will depend on how the compiler writer felt at the time, and may differ from compiler to compiler and version to version of the same compiler. |
Re: doubt
I think xp is right about this.. even i read something like this long back...
|
| All times are GMT +5.5. The time now is 00:04. |