What is stored in a list


Discuss the below:

Q1. 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

Q2. 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];

Q3. 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.

Q4. 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;
else
list[i] = list[i] - i;
}

Q5. 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 :

Prepared by a verified Expert
C/C++ Programming: What is stored in a list
Reference No:- TGS01936583

Now Priced at $30 (50% Discount)

Recommended (91%)

Rated (4.3/5)