Explore BrainMass

Answering 5 C++ language questions focusing on arrays and strings

Do #2, 4, 6, 8, 10 on pages 574 - 577 of C++ a single Microsoft Word file

2. Consider the following declaration:
double passwords[100];
In this declaration, identify the following:
a. The array name
b. The array size
c. The data type of each array component
d. The range of values for the index of the array

4. Determine whether the following array declarations are valid. If a declaration is invalid, explain why.
a. string employees[82];
b. int myArray[50];
c. int SIZE
double list[SIZE];
d. int X = 50;
double list[X - 60];
e. int ids [-30];
f. names string[10];

6. Write C++ statements to do the following.
a. Declare an array beta of 20 component of the type double.
b. Initialize each component of the array beta to 0.
c. Output the value of the fifth component of the array beta.
d. set the value of the ninth component of the array beta to 70.50.
e. Set the value of the twelfth component of beta to four times the value of the eighth component of beta minus 15.
f. Use a for loop to output the value of a component of beta if its index is a multiple of 3.
g. Output the value of the last component of beta.
h. Output the value of beta so that ten components per line are printed.

8. What is stored in list after the following C++ code executes?
int list[10];

for (int i=0; i <5; i++)
list[i[ - i * i - 5;
if (i % 3 == 0)
list[i] = list[i] + i;
list[i] = list[i] - i;

10. What is stored in myList after the following C++ code executes?
double myList[5];

myList[0] = 3.0;
myList[1] = 4.0;

for (int i=2; i < 5; i++)
myList[i] = myList[i - 1] * myList(i - 2);
if (i > 3)
myyList[i] = myList[i] / 4;


Solution Preview

Please check attachment.

a. The array name is passwords
b. The array size is 100
c. The data type is double
d. The range of values for the index is from 0 to 99

a. it is valid
b. it is invalid because square bracket is missing after 50.
c. it ...

Solution Summary

The solution gives detailed steps on answering 5 C++ language questions which focus on arrays and strings.