Initial Values: Step 1: A (3) ++
Initial Values: Step 1: A (3) ++
int[] a = {1, 2, 3, 4, 5,
6, 7 }; a[3]++; a[2] = a[3] + 1; a[6]++; a[5] = a[2] / 2;
Step 1: a[3]++
Step 3: a[6]++
a = {1, 2, 6, 5, 5, 3, 8}
a) A list of lists.
b) A collection of elements stored in rows and columns.
c) A linear collection of elements stored in contiguous memory locations.
d) A data structure with only one element.
a) int arr[5];
b) array<int> arr[5];
c) arr[5] int;
d) int array(5);
Answer: a) int arr[5];
3. What is the index of the first element in an array in most programming languages?
a) 0
b) 1
c) -1
d) It depends on the language.
Answer: a) 0
Copy code
printf("%d", a[2]);
a) 1
b) 2
c) 3
d) 4
Answer: c) 3
Answer: a) The program will compile but cause undefined behavior at runtime.
7. If you want to access the last element of an array arr in Python, which index should you use?
a) 0
b) -1
c) len(arr)
d) arr.size - 1
Answer: b) -1
Copy code
printf("%d", a[3]);
a) 3
b) 0
c) Undefined behavior
d) Compiler error
a) sizeof(arr)
b) sizeof(arr) / sizeof(arr[0])
c) arr.size()
d) length(arr)