Given the array declaration, int a[20], the last (legal)element is written as __
ID: 3616816 • Letter: G
Question
Given the array declaration, int a[20], the last (legal)element is written as _____. A)a[2]B)a[0]
C)a
D)a[20]
E)a[19]
Are the following array initializations correct? If not, whynot? A)int x[4] = {8, 7, 6, 5, 4}
B)int x[] = {8, 7, 6, 5, 4}
C)int x[2] = {8, 7, 6};
D)const int SIZE =4 int x[SIZE]
E)const int SIZE =4 int x[SIZE-4] Given the array declaration, int a[20], the last (legal)element is written as _____. A)a[2]
B)a[0]
C)a
D)a[20]
E)a[19]
Given the array declaration, int a[20], the last (legal)element is written as _____. Are the following array initializations correct? If not, whynot? A)int x[4] = {8, 7, 6, 5, 4}
B)int x[] = {8, 7, 6, 5, 4}
C)int x[2] = {8, 7, 6};
D)const int SIZE =4 int x[SIZE]
E)const int SIZE =4 int x[SIZE-4] Are the following array initializations correct? If not, whynot? A)int x[4] = {8, 7, 6, 5, 4}
B)int x[] = {8, 7, 6, 5, 4}
C)int x[2] = {8, 7, 6};
D)const int SIZE =4 int x[SIZE]
E)const int SIZE =4 int x[SIZE-4] Are the following array initializations correct? If not, whynot?
Explanation / Answer
1) E is the correct answer The elements in the array has index 0, 1, 2,3.....SIZE-2, SIZE-1 [therefore the number of elementsin array are SIZE] AS SIZE= 20 here, the last element would bea[SIZE - 1] = a[20-1] =a[19] 2) A is wrong since size of array is 4 and initialization has 5elements in the parenthesis B is correct since size was not declared, it will take size as thenumber of elements in the parenthesis Therefore size of array x will be 5 and it is avalid initialization C is wrong since size of array is 2 and initialization has 3elements in the parenthesis D is correct, here SIZE=4 and it initializes an array withsize=4.i.e. it can hold 4 elements E is not a valid initialization since there cannot be an array with0 size
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.