Question 1
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int a = 5, b;
b = a++ * 2;
printf("%d %d\n", a, b);
return 0;
}
- A 6 10 Correct
- B 6 12
- C 5 10
- D 6 11
Correct Answer: Option A
a++ supplies the old value 5 to the multiplication, so b = 10; a becomes 6 afterwards.
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!