MCQOPTIONS
Saved Bookmarks
This section includes 29 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of the following are generated from char pointer? |
| A. | char *string = “Hello.”; |
| B. | char *string;scanf("%s", string); |
| C. | char string[] = “Hello.”; |
| D. | char *string = “Hello.”; and char string[] = “Hello.”; |
| Answer» B. char *string;scanf("%s", string); | |
| 2. |
Which of the following is not possible statically in C? |
| A. | Jagged Array |
| B. | Rectangular Array |
| C. | Cuboidal Array |
| D. | Multidimensional Array |
| Answer» B. Rectangular Array | |
| 3. |
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 |
| Answer» B. The name of the files which are passed to the program | |
| 4. |
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 |
| Answer» C. Nothing | |
| 5. |
What are the applications of a multidimensional array? |
| A. | Matrix-Multiplication |
| B. | Minimum Spanning Tree |
| C. | Finding connectivity between nodes |
| D. | All of the mentioned |
| Answer» E. | |
| 6. |
Which of the following operation is possible using a pointer char? (Assuming the declaration is char *a;) |
| A. | Input via %s |
| B. | Generation of the multidimensional array |
| C. | Changing address to point at another location |
| D. | All of the mentioned |
| Answer» D. All of the mentioned | |
| 7. |
What are the different ways to initialize an array with all elements as zero? |
| A. | int array[5] = {}; |
| B. | int array[5] = {0}; |
| C. | int a = 0, b = 0, c = 0; int array[5] = {a, b, c}; |
| D. | All of the mentioned |
| Answer» E. | |
| 8. |
Which of the following declaration are illegal? |
| A. | int a[][] = {{1, 2, 3}, {2, 3, 4, 5}}; |
| B. | int *a[] = {{1, 2, 3}, {2, 3, 4, 5}}; |
| C. | int a[4][4] = {{1, 2, 3}, {2, 3, 4, 5}}; |
| D. | none of the mentioned |
| Answer» B. int *a[] = {{1, 2, 3}, {2, 3, 4, 5}}; | |
| 9. |
What is the size of *ptr in a 32-bit machine (Assuming initialization as int *ptr = 10;)? |
| A. | 1 |
| B. | 2 |
| C. | 4 |
| D. | 8 |
| Answer» D. 8 | |
| 10. |
Which of the following is the correct syntax to send an array as a parameter to function? |
| A. | func(&array); |
| B. | func(#array); |
| C. | func(*array); |
| D. | func(array[size]); |
| Answer» B. func(#array); | |
| 11. |
Which of the following is a correct syntax to pass a Function Pointer as an argument? |
| A. | void pass(int (*fptr)(int, float, char)){} |
| B. | void pass(*fptr(int, float, char)){} |
| C. | void pass(int (*fptr)){} |
| D. | void pass(*fptr){} |
| Answer» B. void pass(*fptr(int, float, char)){} | |
| 12. |
Which of the following is not possible in C? |
| A. | Array of function pointer |
| B. | Returning a function pointer |
| C. | Comparison of function pointer |
| D. | None of the mentioned |
| Answer» E. | |
| 13. |
Which of the following arithmetic operation can be applied to pointers a and b? (Assuming initialization as int *a = (int *)2; int *b = (int *)3;) |
| A. | a + b |
| B. | a – b |
| C. | a * b |
| D. | a / b |
| Answer» C. a * b | |
| 14. |
Comment on an array of the void data type. |
| A. | It can store any data-type |
| B. | It only stores element of similar data type to first element |
| C. | It acquires the data type with the highest precision in it |
| D. | You cannot have an array of void data type |
| Answer» E. | |
| 15. |
A program that has no command line arguments will have argc _________ |
| A. | Zero |
| B. | Negative |
| C. | One |
| D. | Two |
| Answer» D. Two | |
| 16. |
What type of initialization is needed for the segment 'ptr[3] = '3';' to work? |
| A. | char *ptr = “Hello!”; |
| B. | char ptr[] = “Hello!”; |
| C. | both char *ptr = “Hello!”; and char ptr[] = “Hello!”; |
| D. | none of the mentioned |
| Answer» C. both char *ptr = “Hello!”; and char ptr[] = “Hello!”; | |
| 17. |
How to call a function without using the function name to send parameters? |
| A. | typedefs |
| B. | Function pointer |
| C. | Both typedefs and Function pointer |
| D. | None of the mentioned |
| Answer» C. Both typedefs and Function pointer | |
| 18. |
Which of the following is the correct syntax to declare a 3 dimensional array using pointers? |
| A. | char *a[][]; |
| B. | char **a[]; |
| C. | char ***a; |
| D. | all of the mentioned |
| Answer» B. char **a[]; | |
| 19. |
An array of strings can be initialized by _________ |
| A. | char *a[] = {“Hello”, “World”}; |
| B. | char *a[] = {“Hello”, “Worlds”}; |
| C. | char *b = "Hello";char *c = "World";char *a[] = {b, c}; |
| D. | All of the mentioned |
| Answer» E. | |
| 20. |
What is the index of the last argument in command line arguments? |
| A. | argc – 2 |
| B. | argc + 1 |
| C. | argc |
| D. | argc – 1 |
| Answer» E. | |
| 21. |
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 |
| Answer» B. A pointer to an array of character strings that contain the arguments | |
| 22. |
Which of the following can never be sent by call-by-value? |
| A. | Variable |
| B. | Array |
| C. | Structures |
| D. | Both Array and Structures |
| Answer» C. Structures | |
| 23. |
An array of similar data types which themselves are a collection of dissimilar data type are ___________ |
| A. | Linked Lists |
| B. | Trees |
| C. | Array of Structure |
| D. | All of the mentioned |
| Answer» D. All of the mentioned | |
| 24. |
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 |
| Answer» C. argument control, argument variable | |
| 25. |
Which is true for b, if b is defined as “int *b[10];”? |
| A. | The definition only allocates 10 pointers and does not initialize them |
| B. | Initialization must be done explicitly |
| C. | The definition only allocates 10 pointers and does not initialize them & Initialization must be done explicitly |
| D. | Error |
| Answer» D. Error | |
| 26. |
How many number of pointer (*) does C have against a pointer variable declaration? |
| A. | 7 |
| B. | 127 |
| C. | 255 |
| D. | No limits |
| Answer» E. | |
| 27. |
Which is true for a, if a is defined as “int a[10][20];”? |
| A. | a is true two-dimensional array |
| B. | 200 int-sized locations have been set aside |
| C. | The conventional rectangular subscript calculation 20 * row + col is used to find the element a[row, col]. |
| D. | All of the mentioned |
| Answer» E. | |
| 28. |
Which of following logical operation can be applied to pointers? (Assuming initialization int *a = 2; int *b = 3;) |
| A. | a | b |
| B. | a ^ b |
| C. | a & b |
| D. | None of the mentioned |
| Answer» E. | |
| 29. |
What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming declaration int a[5][4][3];) |
| A. | func(a); |
| B. | func(&a);c) func(*a);d) func(**a); |
| Answer» B. func(&a);c) func(*a);d) func(**a); | |