Difficulty: Easy
Correct Answer: 3 Good
Explanation:
Introduction / Context:
This question checks understanding of how C command-line arguments are passed to main on DOS-based compilers such as Turbo C, and how argc (argument count) and argv (argument vector) influence the printed output.
Given Data / Assumptions:
Concept / Approach:
In C, argv[0] holds the program name ("sample" here). Subsequent elements hold each argument token split on spaces: argv[1] = "Good", argv[2] = "Morning". argc is the count of tokens including the program name, so argc = 3 for this invocation.
Step-by-Step Solution:
Verification / Alternative check:
Running with an extra token, e.g., sample A B C, makes argc = 4 and argv[1] = "A", confirming the pattern.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing argv[0] with the first user-supplied argument and assuming spaces remain as a single string without quoting.
Final Answer:
3 Good
Discussion & Comments