Multiple choice

What will be the value of c after the execution of the following program? #include<stdio.h> #include<conio.h> int main() { int c=1,d=0; while(d<=9) { printf( %d%d,++d,++c); } getch(); }

  1. 9

  2. 10

  3. 11

  4. 12

  5. None of these

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

This program will run until d becomes greater than 9. As we can see the value of c (c=1) is greater than d (d=0). So c will always be one greater than the value of d, because both are incrementing at the same time. So, when d = 0 (d <= 9), condition becomes true. So when d becomes 1, c becomes 2, and when d is 9 (d <= 9), which is again true, then d becomes 10 and c becomes 11, which is one greater than d. The program runs 10 times. So final value of c is 11.