C Programming Multiple Choice Question - Array And String
This section focuses on the "Array And String" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. What is the maximun number of dimensions an array in C may have?
A. Two
B. eight
C. sixteen
D. Theoratically no limit. The only practical limits are memory size and compilers
View Answer
Ans : D
Explanation: The maximum size of an array is determined by the amount of memory that a program can access. On a 32-bit system, the maximum amount of memory that can be addressed by a pointer is 2^32 bytes which is 4 gigabytes. The actual limit may be less, depending on operating system implementation details.
2. A one dimensional array A has indices 1....75. Each element is a string and takes up three memory words. The array is stored at location 1120 decimal. The starting address of A[49] is
A. 1264
B. 1164
C. 1167
D. 1267
View Answer
Ans : A
Explanation: Start address of the element = base address of array + number of elements * size of each element = 1120 + 48 * 3 = 1264
3. What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows and 5 columns and starting address of the array is 2000?
A. 2048
B. 2056
C. 2052
D. 2042
View Answer
Ans : C
Explanation: 2000 + 4*(5*2) + 3*4 .
4. Array can be considered as set of elements stored in consecutive memory locations but having __________.
A. Same data type
B. Different data type
C. Same scope
D. None of these
View Answer
Ans : A
Explanation: Array store elements of same data type.
5. Array is an example of _______ type memory allocation.
A. Compile time
B. Run time
C. Both A and B
D. None of the above
View Answer
Ans : A
Explanation: Array allocate memory at compile time
6. Size of the array need not be specified, when
A. Initialization is a part of definition
B. It is a formal parameter
C. It is a declaratrion
D. All of the above
View Answer
Ans : A
Explanation: int arr[] = {1,2,3}; In this case size of array need not to be specified when initialization is a part of defination.
7. The information about an array used in program will be stored in
A. Symbol Table
B. Activation Record
C. Dope Vector
D. Both A and B
View Answer
Ans : C
Explanation: In computer programming, a dope vector is a data structure used to hold information about a data object, e.g. an array, especially its memory layout.
8. The parameter passing mechanism for an array is
A. call by value
B. call by reference
C. call by value-result
D. None of the above
View Answer
Ans : B
Explanation: The parameter passing mechanism for an array is call by reference.This technique uses in/out-mode semantics. Changes made to formal parameter do get transmitted back to the caller through parameter passing. Any changes to the formal parameter are reflected in the actual parameter in the calling environment as formal parameter receives a reference (or pointer) to the actual data.
9. A string that is a formal parameter can be declared
A. An array with empty braces
B. A pointer to character
C. Both A and B
D. None of the above
View Answer
Ans : C
Explanation: A string that is a formal parameter can be declared by both A and B.
10. Which of the following function is more appropriate for reading in a multi-word string?
A. scanf()
B. printf()
C. gets()
D. puts()
View Answer
Ans : C
Explanation: The C library function gets() reads a line from stdin and stores it into the string pointed to by str.
Also check :
Discussion