## Exercise

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

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

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

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

5.Array is an example of _______ type memory allocation.

A. Compile time
B. Run 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

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

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

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

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

A. scanf()
B. printf()
C. gets()
D. puts()

11. Length of the string "letsfindcourse" is

A. 13
B. 14
C. 15
D. 12

12.How will you print \n on the screen?

A. printf("\n");
B. printf('\n');
C. printf("\\n");
D. printf("\"\n"")

13. If the two strings are identical, then strcmp() function returns

A. -1
B. 1
C. 0
D. None

14. Which of the following statements are correct ?
1: A string is a collection of characters terminated by ''.
2: The format specifier %s is used to print a string.
3: The length of the string can be obtained by strlen().
4: The pointer CANNOT work on string.

A. 1,2,3
B. 1,2
C. 2,4
D. 3,4

15.Let x be an array.Which of the following operations is 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
E. III and IV

16. Strcat function adds null character

A. Only if there is space
B. Always
C. Depends on the standard
D. epends on the compiler

17. Which of the following function sets first n characters of a string to a given character?

A. strset()
B. strnset()
C. strcset()
D. strinit()

18. The library function used to find the last occurrence of a character in a string is

A. strnstr()
B. laststr()
C. strrchr()
D. strstr()

19. Which of the following gives the memory address of the first element in array foo, an array with 10 elements?

A. foo
B. &foo
C. foo[0]
D. &foo[0]

20. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?

A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash
D. None of the above

21. An array elements are always stored in ________ memory locations.?

A. Sequential
B. Random
C. Sequential and Random
D. None of the above

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