1. Write C++ statements to do the following:
a. Declare an array alpha of 15 components of type int. int[] alpha = new int[15];
b. Output the value of the 10th component of the alpha array.
System.out.println(alpha[10]);
c. Set the value of the 5th component of the alpha array to 35. alpha[4]=35 d. Set the value of the 9th component of the alpha array to the sum of the 6th and 13th components of the alpha array. Alpha[8]=(6*13)
e. Set the value of the 4th component of the alpha array to three times the value of the 8th component minus 57. alpha[3]=(3*alpha[7])-57; f. Output alpha so that five components appear on each line. int counter = 0; for (int i = 0; i < 3; i++) { counter = (i * 5); System.out.println(alpha[counter] + " " + alpha[counter + 1] + alpha[counter + 2] + " " + alpha[counter + 3] + " " + alpha[counter + 4]); } …show more content…
What is stored in the list array after the following code executes?
int list[5]; for(int j = 0; j < 5; j++) { list[j] = 2 * j + 5; if (j % 2 == 0) { list[j] = list[j] - 3; } }
The numerical values of 2,7,6,11,10
3. What does array index out of bounds mean? What can happen if this occurs in your program? This means that the value given is either a negative or is greater than or equal to the size of the array. If this occurs within your program than you will get a runtime error causing the program to not fully operate.
4. Write C++ statements to define and initialize the following arrays using appropriate data types:
a. An array of heights has 6 components which have the following values: 5.5, 5.8, 6.3, 6.6, 4.9, 5.9. b. An array of weights has 4 components which have the values: 140, 165, 190, 207. c. An array of symbols which contains the following characters: '$', '%', '@', '!', '|',