Multiple choice

How many times will the following loop be executed if the input data item is 01234? while( c = getchar() ! = 0) {

  1. Infinitely

  2. Never

  3. Once

  4. Five

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

The getchar function reads characters one by one. The loop condition checks if the character is not equal to 0. Since the input is 01234, the first character read is '0', which has an ASCII value of 48, not 0. The loop will continue until it hits the end of the input stream, making it effectively infinite or until EOF.