Multiple choice

What would be the output of the following statement? int x=30;int y=5;while(x!=0){ if(x%y==0) printf(n Value of x=%d,x); x=x-10;}

  1. Value of x=10Value of x=20Value of x=30

  2. Value of x=30Value of x=20Value of x=10

  3. Value of x=10Value of x=30Value of x=20

  4. Value of x=30Value of x=10Value of x=20

  5. Value of x=10Value of x=20Value of x=10

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

This is the correct option as value of x is decremented by 10 in each iteration and when value of x becomes equal to 10 when it is further decremented by 10 then the condition specified in the while statement becomes true and there would not be execution of printf() statement.