Write one or more statements that perform the following tasks for and array called fractions:

a) Define a constant integer variable arraySize initialized to 10.
b) Declare an array with arraySize elements of type double, and initialize the elements to 0.
c) Name the fourth element of the array.
d) Refer to array element 4.
e) Assign the value 1.667 to array element 9.
f) Assign the value 3.333 to the seventh element of the array.
g) Print array elements 6 and 9 with two digits of precision to the right of the decimal point, and show the output that is actually displayed on the screen.
h) Print all the array elements using a for statement. Define the integer variable i as a control variable for the loop. Show the output.

a) ```
const int arraySize = 10;
```
b) ```
double fractions[ arraySize ] = { 0.0 };
```
c) ```
fractions[ 3 ]
```
d) ```
fractions[ 4 ]
```
e) ```
fractions[ 9 ] = 1.667;
```
f) ```
fractions[ 6 ] = 3.333;
```
g)```
cout << fixed << setprecision( 2 );
cout << fractions[ 6 ] << ' ' << fractions[ 9 ] << endl;
Output: 3.33 1.67.
```
h) ```
for ( int i = 0; i < arraySize; i++ )
cout << "fractions[" << i << "] = " << fractions[ i ] << endl;
```

Computer Science & Information Technology

You might also like to view...

One of the limitations of working with Ruby's built-in classes is that you can read but not modify property values.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Data currency is preserved in a centralized database by

A. partitioning the database B. using a lockout procedure C. replicating the database D. implementing concurrency controls

Computer Science & Information Technology