Multiple choice

What will be the output of the following program?

void main()

{
int p,q,r;
p=10;
q=20;
r=30;
if ((p>10)||(q<30))
if(r>p)
cout<<”Wintern”;
else if((p<q)&&(r<20))
cout<<”Summern”;
cout<<”Autumn”;}

  1. Winter Autumn

  2. Autumn

  3. Summer Autumn

  4. Winter

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Tracing the nested conditions with p=10, q=20, r=30: First if (p>10)||(q<30) evaluates to (false)||(false) = false, so we skip to the final cout statement and print 'Autumn'. The inner if-else blocks are never executed.