MCQ Single Best Answer Easy

QWhat is the output of the following C code?

#include <stdio.h>

int main() {
    int i = 0;
    while (i < 5) {
        printf("%d ", i);
        i++;
    }
    return 0;
}

ID: #7201 Fundamentals of C Language 212 views
Question Info
#7201Q ID
EasyDifficulty
Fundamentals of C LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 0 1 2 3 4
  • B 1 2 3 4 5
  • C 5 4 3 2 1
  • D The code will result in an infinite loop
Correct Answer: Option A

Explanation

Answer: A

Explanation: The while loop continues to execute as long as i is less than 5. Inside the loop, the value of i is printed using printf, and then incremented by 1. Therefore, the output will be "0 1 2 3 4".

Share This Question

Challenge a friend or share with your study group.