🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. A program is run as ./calc 5 + 7. What is argc?
  2. Q2. For the same command ./calc 5 + 7, what is argv[2]?
  3. Q3. What is always stored in argv[argc]?
  4. Q4. What does this print? (code)
  5. Q5. Why is strtol better than atoi for reading a number from argv?
  6. Q6. A program uses argv[1] without checking argc and is run with no arguments. What happens?
  7. Q7. Which is the conventional exit code for success?
  8. Q8. How many words does the shell pass for ./show "New Delhi" 110001?
  9. Q9. Which test correctly checks whether the first argument is the flag -v?
  10. Q10. What does this print? (code)