This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Command Line Arguments – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What does argc and argv indicate in command-line arguments?
(Assuming: int main(int argc, char *argv[]) )
a) argument count, argument variable
b) argument count, argument vector
c) argument control, argument variable
d) argument control, argument vector
View Answer
Explanation: None.
2. Which of the following syntax is correct for command-line arguments?
a)
int main(int var, char *varg[])
b)
int main(char *argv[], int argc)
c)
int main() { int argv, char *argc[]; }
d) none of the mentioned
View Answer
Explanation: None.
3. In linux, argv[0] by command-line argument can be occupied by _________
a) ./a.out
b) ./test
c) ./fun.out.out
d) all of the mentioned
View Answer
Explanation: All the options mentioned (./a.out, ./test, ./fun.out.out) are simply the command without any argument. A command is always stored as argument vector zero i.e., argv[0] always contain the command where as argv[1], argv[2], etc. contains the arguments to the commands, if any.
4. What type of array is generally generated in Command-line argument?
a) Single dimension array
b) 2-Dimensional Square Array
c) Jagged Array
d) 2-Dimensional Rectangular Array
View Answer
Explanation: None.
5. What will be the output of the following C statement? (assuming the input is “cool brother in city”)
printf(“%s\n”, argv[argc]);
a) (null)
b) City
c) In
d) Segmentation Fault
View Answer
Explanation: None.
6. What is the first argument in command line arguments?
a) The number of command-line arguments the program was invoked with;
b) A pointer to an array of character strings that contain the arguments
c) Nothing
d) None of the mentioned
View Answer
Explanation: None.
7. What is the second argument in command line arguments?
a) The number of command-line arguments the program was invoked with;
b) A pointer to an array of character strings that contain the arguments, one per string
c) Nothing
d) None of the mentioned
View Answer
Explanation: None.
8. What is argv[0] in command line arguments?
a) The name by which the program was invoked
b) The name of the files which are passed to the program
c) Count of the arguments in argv[] vector
d) None of the mentioned
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check C Books
- Watch Advanced C Programming Videos
- Apply for C Internship
- Check Computer Science Books
- Practice BCA MCQs