While (87) printf(“computer”); The above C statement will

2014

While (87) printf(“computer”); The above C statement will

  1. A.

    print “computer” 87 times

  2. B.

    print “computer” 0 times

  3. C.

    print “computer” 1 times

  4. D.

    print “computer” infinite times

Attempted by 878 students.

Show answer & explanation

Correct answer: D

Answer: The statement will print "computer" infinite times.

Why: In C, a while loop continues while its condition evaluates to true. Any non-zero integer is treated as true. The constant 87 is non-zero, so the condition is always true and the printf statement is executed repeatedly until the program is terminated.

  • The expression 87 evaluates to a non-zero value, which is true.

  • while(condition) executes the following statement repeatedly as long as the condition remains true.

  • Since the condition never becomes false and there is no break, the printf runs indefinitely, producing repeated "computer" output until the program is stopped.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor