Question 4
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
const char *s = "LearnFrenzy";
printf("[%.3s][%8.3s][%-8.5s][%2s]\n", s, s, s, "C");
return 0;
}
- A [Lea][ Lea][Learn ][ C] Correct
- B [Lea][Lea ][ Learn][C ]
- C [LearnFrenzy][ Lea][Learn ][ C]
- D [Lea][ Lea][Learn ][C]
Correct Answer: Option A
For strings, precision is the maximum number of characters printed and width the minimum field size: "Lea", then "Lea" right-aligned in 8, "Learn" left-aligned in 8, and "C" padded to 2.
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!