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
- C Cmdline: command line, line programs, arguments, converts, atoi argv, argv argc, checking, argc char
- C Cmdline Output: argv atoi, argv printf, argc char, atoi argv, char argv, program, prints
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
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.
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.
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".