The correct answer is
b. 10
-
Explanation:
Ideally we are setting the value of a = 10 only if a > 30.
But the semi-colon after if(a>30); changes everything
Semi-colon means end of command. So by writing the semi-colon after if(a>30); we are ending the if statement and the next line a = 10; is not dependent on the condition anymore.
Now a= 10; executes like normal statement setting the value of a as 10 which is eventually printed in cout<<a;
-
Explanation:
Ideally we are setting the value of a = 10 only if a > 30.
But the semi-colon after if(a>30); changes everything
Semi-colon means end of command. So by writing the semi-colon after if(a>30); we are ending the if statement and the next line a = 10; is not dependent on the condition anymore.
Now a= 10; executes like normal statement setting the value of a as 10 which is eventually printed in cout<<a;
This is a free to join group for students and parents, But before you join, here are some rules.
- Be respectful, Be respectful, Be respectful
- Don’t spam, Don’t spam, Don’t spam