Question 8
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
#include <string.h>
int main(void) {
const char *msg = "Learn" "Frenzy" " 2026";
printf("%s %zu\n", msg, strlen(msg));
return 0;
}
- A LearnFrenzy 2026 16 Correct
- B Learn 5
- C LearnFrenzy 2026 18
- D Compilation error
Correct Answer: Option A
The compiler joins adjacent string literals into one before the program runs: "LearnFrenzy 2026", 5 + 6 + 5 = 16 characters. Handy for splitting long text over several lines.
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!