VKV SirTest Lab

Command Line Arguments: viva questions and MCQs

Computer Programming Lab (C), Unit 12. 100+ Command Line Arguments questions with explanations (Computer Programming Lab (C)). Topics: C Cmdline, C Cmdline Output. Take a free test now.

Topics

Key terms: command line, line programs, arguments, converts, atoi argv, argv argc, argv atoi, argv printf, argc char, char argv, program

Sample questions with answers

  1. An example of command line usage is:

    Options: A) printf("hi")   B) int x;   C) #include   D) gcc file.c -o file

    Answer: D) gcc file.c -o file. Compiler options are arguments.

  2. If a program expects 2 arguments but gets 1, it should:

    Options: A) Assume zero silently   B) Delete files   C) Print a usage message and exit   D) Crash

    Answer: C) Print a usage message and exit. Defensive programming.

  3. In C command line programs, "Quoted argument" means:

    Options: A) Converts a string to a double   B) Name (path) of the program itself   C) Argument in quotes that may contain spaces, e.g. "hello world"   D) Converts a string to long with error checking

    Answer: C) Argument in quotes that may contain spaces, e.g. "hello world". Quoted argument: Argument in quotes that may contain spaces, e.g. "hello world".

Take a free Command Line Arguments test

All units of Computer Programming Lab (C)