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;
```
You might also like to view...
To change to the completed application’s directory, we opened a command window and used the ________ command to change to the directory (also called a folder) for the Painter application.
a. chge b. cdir c. cd d. changeDirectory
The original Ethernet operated at
a. 4 Mbps b. 10 Mbps c. 16 Mbps d. 100 Mbps
What is a Javadoc comment?
What will be an ideal response?
The decision table below shows fines imposed for speeding violations. Write a code segment that assigns the correct fine to type double variable fine based on the value of type int variable speed.
Speed (mph) Fine ($) 65 or less 0 66-70 15.00 71-75 30.00 76-80 75.00 over 80 100.00