22226 PCI MCQ (Programming in C) | Unit 4: Array and Structure

cwipedia

Department of Computer Engineering

Academic Year 2020-21


Class: Computer & IT

Subject: 22226 PCI (Programming in C) MCQ 


Unit 4: Array and Structure


MCQ Question Bank with Answers


2nd SEM ALL SUBJECT MCQ:           click here

     


To Download PDF scroll to the bottom




1. Which of these best describes an array?

a) A data structure that shows a hierarchical behavior

b) Container of objects of similar types

c) Arrays are immutable once initialised

d) Array is not a data structure

Answer: b


2. How do you initialize an array in C?

a) int arr[3] = (1,2,3);

b) int arr(3) = {1,2,3};

c) int arr[3] = {1,2,3};

d) int arr(3) = (1,2,3);

Answer: c


3. What will be the output of this program?

main()

{

printf("cwipedia");

main();

}

a) Wrong statement

b) It will keep on printing cwipedia

c) It will Print cwipedia once

d) None of the these

Answer: b



4. What is required in each C program?

a) The program must have at least one function.

b) The program does not require any function.

c) Input data

d) Output data

Answer: a


5. Array elements are always stored in ______ memory locations.

a) Random

b) Sequential

c) Sequential and Random

d) None of the above

Answer: a



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

a) 2

b) 3

c) 12

d) No Limit

Anser: d



7. Let x be an array. Which of the following operations are illegal?

I. ++x

II. x+1

III. x++

IV. x*2

a) I and II

b) I, II and III

c) II and III

d) I, III and IV

Answer: d



8. What will be the output of the program if the array begins at 1000 and each integer

occupies 2 bytes?

void main() {

int arr[2][2] = { 1, 2, 3, 4};

printf("%u, %u", arr+1, &arr+1);

}

a) 1004 1008

b) 1002 1008

c) 1002 1002

d) 1008 1002

Answer:a



9. What are the advantages of arrays?

a) Objects of mixed data types can be stored

b) Elements in an array cannot be sorted

c) Index of first element of an array is 1

d) Easier to store elements of same data type

Answer: d


10. What are the disadvantages of arrays?

a) Data structure like queue or stack cannot be implemented

b) There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size

c) Index value of an array can be negative

d) Elements are sequentially accessed

Answer: b



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

A. Two

B. eight

C. sixteen

D. Theoretically no limit. The only practical limits are memory size and compilers

Ans : D



12. 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

Ans : A



13. 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 the starting address of the array is 2000?

A. 2048

B. 2056

C. 2052

D. 2042

Ans : C



14. Arrays can be considered as a 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

Ans : A



15. 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



16. 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 declaration

D. All of the above

Ans : A



17. 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

Ans : C



18. 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

Ans : B



19. 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

Ans : C.



20. Which of the following functions is more appropriate for reading in a multi-word string?

A. scanf()

B. printf()

C. gets()

D. puts()

Ans : C



Download


Happy Learning!

cwipedia.in



Comments