LearnFrenzy
Sign in Take a free test

Strings · Predict the Output · Question 8

Adjacent string literals are joined – output Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What is the output of the following C program?

main.c
#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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links