Question 2
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int n = printf("C23\n");
printf("%d\n", printf("Hi "));
printf("%d\n", n);
return 0;
}
- A C23 Hi 3 4 Correct
- B C23 Hi 2 3
- C C23 3Hi 4
- D C23 Hi 3 3
Correct Answer: Option A
printf returns the number of characters written. "C23\n" is 4 characters (the newline counts); the inner call prints "Hi " and returns 3, which the outer call then prints.
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!