Question: Tutorial 5 Write a C++ statement(s) that accomplish the following array: Declare an array named myList of 20 components of type int. Display the value
Tutorial 5
- Write a C++ statement(s) that accomplish the following array:
- Declare an array named myList of 20 components of type int.
- Display the value of the tenth component of the array myList.
- Set the value of the fifth component of the array myList to 35.
- Set the value of the ninth component of the array myList to the sum of the sixth and thirteen components of the array myList.
- Set the value of the fourth component of the array myList to three times the value of the eight components minus 30.
- Declare a new array named specialSymbols of type char. Initialize this array to the following values: $, #, %, @, &, !, =
- Consider the following declaration:
string superheroes[5] = {Batman, Superman, X-Men,
Spiderman, Ironman };
In this declaration, identify the following:
- The array name
- The array size
- The data type of each array component
- The range of values for the index of the array.
- Write code to change superhero in fourth component with catwoman.
3. Answer the following:
int values[20];
- How many elements does the array have?
- What is the subscript of the second element in the array?
- What does the following statement do?
values[1] = 10;
4. Answer the following:
int values[7] = { 1, 2, 3, 4, 5, 6, 7 };
What does the following statement display?
- cout << (values[3] + values[4]);
- cout << (values[5] - values[1]);
- cout << (values[6] * values[2]);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
