ISRO | ISRO CS 2015 | Question 67
Consider the following program fragment
if(a > b)
if(b > c)
s1;
else s2;
s2 will be executed if
(A) a <= b
(B) b > c
(C) b >= c and a <= b
(D) a > b and b <= c
Answer: (D)
Explanation: The code actually works like:
if(a > b)
{
if(b > c)
s1;
else s2;
}
Outer if statement has a scope till the end of inner if and else statements. In order to execute s2, (a>b) should be true so the control enters the inner block and (b>c) should be false. So, (b<=c) should be true.
Correct answer is (D).
Quiz of this Question
Last Updated :
05 Apr, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...