Machine-translated by Google. Questions are authored in English.
Top

Arrays Questions and Answers

81.

If storage class is missing in the array definition, by default it will be taken to be 

Answer: A

Correct answer: either automatic or external depending on the place of occurrence

With no storage class written, the default depends on where the definition appears. Inside a function it is auto - allocated on the stack, uninitialised, and gone when the function returns. At file scope it is external - allocated for the life of the program and zero-initialised.

Please log in or register to report this question.

82.

The information about an array used in a program will be stored in

Answer: B

Correct answer: Dope vector

A dope vector is the run-time descriptor of an array: base address, element size, number of dimensions and the bounds of each. It is what makes address computation, and bounds checking in languages that do it, possible. A symbol table is a compile-time structure of names and types; an activation record holds one call’s local storage.

Please log in or register to report this question.

Answer: A

Correct answer: Integer Array of size 20

int arr[20]; reserves room for 20 values of type int, laid out consecutively, with subscripts 0 to 19. Read the declaration outwards from the name: arr is an array of 20, of int.

Please log in or register to report this question.

84.

How many elements does the array below have?

int a[20]

 

Answer: C

Correct answer: 20

The number in the declarator is the count of elements, so int a[20] has 20 of them, with subscripts 0 to 19. Do not confuse this with the number of bytes, which would be \(20 \times \text{sizeof(int)}\).

Please log in or register to report this question.

Answer: C

Correct answer: Array of Integer Pointers of size 20

Subscript binds more tightly than the dereference, so int *ptr[20] groups as int *(ptr[20]): an array of 20 pointers to int. A pointer to an array of 20 ints would need parentheses in the other place - int (*ptr)[20].

Please log in or register to report this question.

Answer: A

Correct answer: char name[6] = {'I','N','D','I','A','\0'}

A C string is a character array ending in a terminating null, so “INDIA” needs six cells: five letters and '\0'. Single quotes make characters; double quotes would make five separate strings. And an array cannot be assigned to after declaration, so name = "INDIA"; is not valid either. (char name[6] = "INDIA"; would also work - the compiler supplies the null.)

Please log in or register to report this question.

87.

Below is an example of -

int RollNum[30][4];

 

Answer: B

Correct answer: 2-D Array

int RollNum[30][4]; has two subscripts, so it is a two-dimensional array - 30 rows of 4 columns, 120 integers in all. The number of dimensions is simply the number of bracket pairs, not the values inside them.

Please log in or register to report this question.

88.

O(N)(linear time) is better than O(1) constant time.

Answer: B

Correct answer: False

\(O(1)\) means the work does not grow with the input at all, while \(O(N)\) grows in proportion to it. For any large enough \(N\) the constant-time operation wins, so the statement is false. This is why a hash lookup is preferred to a linear scan.

Please log in or register to report this question.

Answer: D

Correct answer: All of these

All three are true of C. Constant expressions such as 2*60*60 are folded at compile time. Adjacent string literals are concatenated by the compiler, so "abc" "def" becomes one string. And the size of an array must be known when the code is compiled, which is why the bound has to be a constant expression rather than a variable.

Please log in or register to report this question.

90.

What is the maximum number of dimensions an array in C may have?

Answer: D

Correct answer: Theoretically no limit. The only practical limits are memory size and compilers

The standard fixes no maximum number of dimensions; it only requires an implementation to support a certain depth of declarator nesting. So the limit is practical - how much memory the array would need, and how deeply the compiler will nest. Note that memory grows as the product of the bounds, so even four modest dimensions can exhaust it.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Arrays Questions and Answers || Arrays MCQ Questions and Answers || Arrays GK Questions and Answers || Arrays GK MCQ Questions || Arrays Multiple Choice Questions and Answers || Arrays GK || GK on Arrays || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming