MCQ Single Best Answer Easy

QWhat is the output of the following C code?

#include <stdio.h>

int main() {
    int x = 5;
    if (x > 10) {
        printf("x is greater than 10");
    }
    else {
        printf("x is less than or equal to 10");
    }
    return 0;
}

ID: #7200 Fundamentals of C Language 313 views
Question Info
#7200Q ID
EasyDifficulty
Fundamentals of C LanguageTopic

Choose the Best Option

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

  • A x is greater than 10
  • B x is less than or equal to 10
  • C The code will result in a runtime error
  • D The code will result in a compile error
Correct Answer: Option B

Explanation

Answer: B

Explanation: The if statement checks if x is greater than 10, which it is not. Therefore, the code inside the else block is executed, resulting in the output "x is less than or equal to 10".

Share This Question

Challenge a friend or share with your study group.