MCQ Practice Single Best Answer Topic: Fundamentals of C Language

Q What 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;
}

Question ID
#7200
Subchapter
Fundamentals of C Language
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is 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: 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

Share this MCQ with your friends or study group.