CBSE Class 11 Computer Science Question 94 of 161

Flow of Control — Question 3

Back to all questions
3
Question

Question 3

What is the output produced by the following code?

x = 1                        
if x > 3 :
   if x > 4 :                
         print ("A", end = ' ')
   else :                    
         print ("B", end = ' ')
elif x < 2:                  
   if (x != 0):
         print ("C", end = ' ')
print ("D")                  

Answer

Output
C D
Explanation

As value of x is 1 so statements in the else part of outer if i.e. elif x < 2: will get executed. The condition if (x != 0) is true so C is printed. After that the statement print ("D") prints D.

Answer