C Programming - Command Line Arguments
Question 1
|
What does argv and argc indicate in command-line arguments? (Assuming: int main(int argc, char *argv[]) )
argument count, argument variable
| |
argument count, argument vector
| |
argument control, argument variable
| |
argument control, argument vector
|
Question 2
|
Which of the following syntax is correct for command-line arguments?
int main(int var, char *varg[])
| |
int main(char *argv[], int argc)
| |
int main() { int argv, char *argc[]; }
| |
Both (a) and (b)
|
Question 3
|
In linux, argv[0] by command-line argument can be occupied by
./a.out
| |
./test
| |
./fun.out.out
| |
All of the mentioned
|
Question 4
|
What type of array is generally generated in Command-line argument?
Single dimension array
| |
2-Dimensional Square Array
| |
Jagged Array
| |
2-Dimensional Rectangular Array
|
Question 5
|
What would be the output if we try to execute following segment of code (assuming the following input “cool brother in city”)? printf(“%s\n”, argv[argc]);
(null)
| |
City
| |
In
| |
Segmentation Fault
|
Question 6
|
The first argument in command line arguments is
The number of command-line arguments the program was invoked with;
| |
A pointer to an array of character strings that contain the arguments
| |
Nothing
| |
Both a & b
|
Question 7
|
The second (argument vector) in command line arguments is
The number of command-line arguments the program was invoked with;
| |
A pointer to an array of character strings that contain the arguments,one per string.
| |
Nothing
| |
Both a & b
|
Question 8
|
argv[0] in command line arguments, is
The name by which the program was invoked
| |
The name of the files which are passed to the program
| |
Count of the arguments in argv[] vector
| |
Both a & b
|
Question 9
|
A program that has no command line arguments will have argc
Zero
| |
Negative
| |
One
| |
Two
|
Question 10
|
The index of the last argument in command line arguments is
argc – 2
| |
argc + 1
| |
argc
| |
argc – 1
|
Question 11
|
What is the output of this C code (if run with no options or arguments)?
0
| |
1
| |
Depends on the platform
| |
Depends on the compiler
|
Question 12
|
What is the output of this C code (run without any commandline arguments)?
Compile time error
| |
Executablefilename
| |
Segmentation fault
| |
Undefined
|
Question 13
|
What is the output of this C code (run without any commandline arguments)?
Segmentation fault/code crash
| |
Executable file name
| |
Depends on the platform
| |
Depends on the compiler
|
Question 14
|
What is the output of this C code (run without any commandline arguments)?
Segmentation fault/code crash
| |
Executable file name
| |
Depends on the platform
| |
Depends on the compiler
|
Question 15
|
What is the output of this C code (run without any command line arguments)?
Segmentation fault/code crash
| |
Executable file name
| |
Depends on the platform
| |
Depends on the compiler
|
Question 16
|
What is the output of this C code(run without any command line arguments)?
Segmentation fault/code crash
| |
Executable file name
| |
Depends on the platform
| |
Depends on the compiler
|
Check Your Answers:
1. B
2. A
3. D
4. C
5. A
6. A
7. B
8. A
9. C
10. D
11. B
12. B
13. A
14. A
15. B
16. A
0 comments:
Post a Comment