LearnFrenzy
Sign in Take a free test

Command Line Arguments · Predict the Output · Question 2

First character of each argument – output Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 2 Back to Exercise

What is the output of the following C program when it is run as shown?

Run as: ./app Learn Frenzy 2026

main.c
#include <stdio.h>

int main(int argc, char *argv[]) {
    for (int i = 1; i < argc; i++)
        putchar(argv[i][0]);
    putchar('\n');
    return 0;
}
  • A LF2 Correct
  • B LearnFrenzy2026
  • C .LF2
  • D LF
Correct Answer: Option A

argv[i] is a string, so argv[i][0] is its first character: L, F and 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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links