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

a) 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 in-
teger variable i as a control variable for the loop. Show the output.

```
a) const size_t arraySize{10};
b) array fractions{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 (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
```

Computer Science & Information Technology

You might also like to view...

Some smartphones support additional memory through ________

A) micro SD Flash cards B) operating system swap files C) Global Positioning System (GPS) D) Bluetooth connectivity

Computer Science & Information Technology

If you click the wrong tag, how can you turn it off?

A) Click the one you wanted B) Right-click the tag C) Click it again to turn it off D) Scroll through the list and click one

Computer Science & Information Technology