Question 11
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int x = 3, count = 0;
if (x > 5)
count++;
count += 10;
printf("%d\n", count);
return 0;
}
- A 10 Correct
- B 0
- C 11
- D 1
Correct Answer: Option A
Without braces only the first statement belongs to the if. count += 10; always runs, despite its indentation. Compilers warn (-Wmisleading-indentation); always use braces.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!