← All topics
Quiz: Command-Line Arguments in C: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. A program is run as ./calc 5 + 7. What is argc?
- Q2. For the same command ./calc 5 + 7, what is argv[2]?
- Q3. What is always stored in argv[argc]?
- Q4. What does this print? (code)
- Q5. Why is strtol better than atoi for reading a number from argv?
- Q6. A program uses argv[1] without checking argc and is run with no arguments. What happens?
- Q7. Which is the conventional exit code for success?
- Q8. How many words does the shell pass for ./show "New Delhi" 110001?
- Q9. Which test correctly checks whether the first argument is the flag -v?
- Q10. What does this print? (code)