Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2015 | Question 67
  • Difficulty Level : Medium
  • Last Updated : 05 Apr, 2018

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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :