Write one or more statements that perform the following tasks for an array called fractions:
) Define a constant variable arraySize to represent the size of an array and initialize it 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) Display array elements 6 and 9 with two digits of precision to the right of the decimal
point, and show the output that’s actually displayed on the screen.
h) Display all the array elements using a counter-controlled for statement. Define the integer variable i as a control variable for the loop. Show the output.
i) Display all the array elements separated by spaces using a range-based for statement.
```
a) const size_t arraySize{10};
b) array
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 (size_t i{0}; i < fractions.size(); ++i) {
cout << "fractions[" << i << "] = " << fractions[i] << endl;
} Output: fractions[0] = 0.0
fractions[1] = 0.0
fractions[2] = 0.0
fractions[3] = 0.0
fractions[4] = 0.0
fractions[5] = 0.0
fractions[6] = 3.333
fractions[7] = 0.0
fractions[8] = 0.0
fractions[9] = 1.667
i) for (double element : fractions)
cout << element << ' ';
```
You might also like to view...
A(n) _________________________ is a router buffering system used to hold packets when the router is congested.
Fill in the blank(s) with the appropriate word(s).
Which preview mode will show a preview with the bleed area included, but not the slug area?
What will be an ideal response?