+ 2
explain
int x=(5+8)/10; if(x) cout << "10"; else cout << "20"; //what should be answer
4 Answers
+ 11
Declaring an integer variable named x and assigning it a value of (5+8) or 13/10 i.e., 1.
The program takes 1 as true. As the if statement checks the condition and then executes the block of code if the result is true otherwise not if false. So, the first statement results in true giving 10 as the output.
Note : If the condition had been false or 0, then the else statement would be executed and not the if one.
+ 11
@Sreejith : Then maybe the quiz was wrong. Please if you again come through any wrong questions in challenges, report them immediately :]
+ 2
ok thanks
+ 1
it was In challenge and answer was 20