MCQOPTIONS
Saved Bookmarks
This section includes 70 Mcqs, each offering curated multiple-choice questions to sharpen your Command Line Arguments knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
If the following program (myproc.c) is present in the directory "C: TC" then what will be output of the program if run it from DOS shell? /* myproc.c */ #include int main(int argc, char *argv[]) { printf("%s", argv[0]); return 0; } |
| A. | SAMPLE.C |
| B. | C: TC MYPROC.EXE |
| C. | C: TC |
| D. | Error |
| Answer» C. C: TC | |
| 52. |
Which of the following statements are FALSE about the below code? int main(int ac, char *av[]) { } |
| A. | ac contains count of arguments supplied at command-line |
| B. | av[] contains addresses of arguments supplied at a command line |
| C. | In place of ac and av, argc and argv should be used. |
| D. | The variables ac and av are always local to main() |
| Answer» D. The variables ac and av are always local to main() | |
| 53. |
What will be the output of this program ? |
| A. | (null) |
| B. | B. |
| C. | C. |
| D. | D. |
| Answer» B. B. | |
| 54. |
Which is the correct form to declare main with command line arguments ? |
| A. | int main(int argc, char argv[]){ } |
| B. | B. |
| C. | C. |
| D. | D. |
| Answer» C. C. | |
| 55. |
What will be the output of this program (prg_1.c)? #include int main(int argc,char* argv[]) { printf("%d",argc); return 0; } |
| A. | 4 |
| B. | 5 |
| C. | 6 |
| D. | 3 |
| Answer» C. 6 | |
| 56. |
What is the output of this C code? #include int main() { int i = 10; int *p = &i; foo(&p); printf("%d ", *p); printf("%d ", *p); } void foo(int **const p) { int j = 11; *p = &j; printf("%d ", **p); } |
| A. | 11 11 11 |
| B. | 11 11 Undefined-value |
| C. | Compile time error |
| D. | Segmentation fault/code-crash |
| Answer» C. Compile time error | |
| 57. |
What is the output of this C code? #include int main() { int i = 11; int *p = &i; foo(&p); printf("%d ", *p); } void foo(int *const *p) { int j = 10; *p = &j; printf("%d ", **p); } |
| A. | Compile time error |
| B. | 10 10 |
| C. | Undefined behaviour |
| D. | 10 11 |
| Answer» B. 10 10 | |
| 58. |
What is the output of this C code? #include int main() { int i = 97, *p = &i; foo(&p); printf("%d ", *p); return 0; } void foo(int **p) { int j = 2; *p = &j; printf("%d ", **p); } |
| A. | 2 2 |
| B. | 2 97 |
| C. | Undefined behaviour |
| D. | Segmentation fault/code crash |
| Answer» B. 2 97 | |
| 59. |
What will be the output of the following C code? #include main() { typedef int a; a b=2, c=8, d; d=(b*2)/2+8; printf("%d",d); } |
| A. | 10 |
| B. | 16 |
| C. | 8 |
| D. | error |
| Answer» B. 16 | |
| 60. |
What is the output of this C code? #include int main() { int i = 97, *p = &i; foo(&i); printf("%d ", *p); } void foo(int *p) { int j = 2; p = &j; printf("%d ", *p); } |
| A. | 2 97 |
| B. | 2 2 |
| C. | Compile time error |
| D. | Segmentation fault/code crash |
| Answer» B. 2 2 | |
| 61. |
What is the output of this C code? #include void foo(int*); int main() { int i = 10, *p = &i; foo(p++); } void foo(int *p) { printf("%d n", *p); } |
| A. | 10 |
| B. | Some garbage value |
| C. | Compile time error |
| D. | Segmentation fault |
| Answer» B. Some garbage value | |
| 62. |
Which of the following is correct about the first parameter of the main function? |
| A. | First argument is of int type |
| B. | Stores the count of command line arguments |
| C. | First argument is non-negative |
| D. | All of the mentioned |
| Answer» E. | |
| 63. |
Which of the following is correct to interpret Hello World as a single argument? 1. $ ./output 'Hello World' 2. $ ./output Hello World |
| A. | Only 1 |
| B. | Only 2 |
| C. | Both 1 and 2 |
| D. | Neither 1 nor 2 |
| Answer» D. Neither 1 nor 2 | |
| 64. |
What does the second parameter of the main function represent? |
| A. | Number of command line arguments |
| B. | List of command line arguments |
| C. | Dictionary of command line arguments |
| D. | Stack of command line arguments |
| Answer» C. Dictionary of command line arguments | |
| 65. |
What is the signature of math in function using command line arguments? |
| A. | int main(int argc, char const *argv[]); |
| B. | int main(int argc, char const **argv); |
| C. | int main(int argc, char **argv); |
| D. | all of the mentioned |
| Answer» E. | |
| 66. |
What does the first parameter of the main function represent? |
| A. | Number of command line arguments |
| B. | List of command line arguments |
| C. | Dictionary of command line arguments |
| D. | Stack of command line arguments |
| Answer» B. List of command line arguments | |
| 67. |
Which is the correct way of handling arguments with spaces? |
| A. | Use single quotes |
| B. | Either single or double quotes |
| C. | Use double quotes |
| D. | There is no way of handling arguments with space |
| Answer» C. Use double quotes | |
| 68. |
Which of the following gives the name of the program if the second parameter to the main fucntion is char **argv? |
| A. | argv[3] |
| B. | argv[1] |
| C. | argv[0] |
| D. | argv[2] |
| Answer» D. argv[2] | |
| 69. |
Which character is used to separate different arguments? |
| A. | # |
| B. | $ |
| C. | space |
| D. | | |
| Answer» D. | | |
| 70. |
Which of the following is correct about the second parameter of the main function? |
| A. | Second parameter is an array of character pointers |
| B. | First string of the list is the name of the program s output fle |
| C. | The string in the list are separated by space in the terminal |
| D. | All of the mentioned |
| Answer» E. | |