# Suppose v is an array with 100 int elements. if 100 is assigned to v[100]. what happens?

1. Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code.
2. An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array? Shows the code.
3. Consider the declaration: int v[1]; What is the index of the last element of this array?
4. Declare an array named a of 10 int elements and initialize the elements (starting with the first) to the values 10, 20, …, 100, respectively.
5. Declare an array named taxRates of 5 elements of type double and initialize the elements (starting with the first) to the values 0.10, 0.15, 0.21, 0.28, 0.31, respectively.
6. Write a statement to declare and initialize an array of ints named denominations that contains exactly six elements. Your declaration statement should initialize the elements of the array to the following values: 1, 5, 10, 25, 50, 100. (The value 1 goes into the first element; the value 100 to the last.)
7. Given the array a, write an expression that refers to the first element of the array.
8. Given an array a, declared to contain 34 elements, write an expression that refers to the last element of the array.

1. Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code.
v[100] refers to 101th element of v. In C and C++, though the size of the array is 100 you can still access 101th element as arrays internally work as pointers that point to continuous memory locations. Array always point to the first element in the array. In languages like Java and C# we cannot the element out the array size it throws index out of bounds exception.
2. An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array? Shows the code.
Answer: The largest integer that can be used as an index is 999. Since indexing starts from 0 the last index of array of 1000 elements is 999. The indexes will be [0] [1] … [998][999]
Code: int arr[1000]; //array of 1000 element
arr[999] is the code to access the largest integer that can be used as index. 3. Consider the declaration: int v[1]; What is the index of the last element of this array?
Answer: Index of the last element of v is 0.
As the size of the array v is 1, v has only one element whose index is 0. Hence index of the first and last element in v is 0.
4. Declare an array named a of 10 int elements and initialize the elements (starting with the first) to the values 10, 20, …, 100, respectively.