Write C++ statements to accomplish each of the following:

a) Display the value of element 6 of character array alphabet.
b) Input a value into element 4 of one-dimensional floating-point array grades.
c) Initialize each of the 5 elements of one-dimensional integer array values to 8.
d) Total and display the elements of floating-point array temperatures of 100 elements.
e) Copy array a into the first portion of array b. Assume that both arrays contain doubles and that arrays a and b have 11 and 34 elements, respectively.
f) Determine and display the smallest and largest values contained in 99-element floating- point array w.


```
a) cout << alphabet[6] << '\n';
b) cin >> grades[4];
c) array values{8, 8, 8, 8, 8};
d) double total{0.0};
for (int k{0}; k < 100; ++k) {
total += temperatures[k];
cout << temperatures[k] << '\n';
}
or
double total{0.0};
for (int temp : temperatures) {
total += temp;
cout << temp << '\n';
}
e) for (int i{0}; i < 11; ++i) {
b[i] = a[i];
}
f) double smallest{w[0]};
double largest{w[0]};
for (int j{1}; j < 99; ++j) {
if (w[j] < smallest) {
smallest = w[j];
}
else if (w[j] > largest) {
largest = w[j];
}
}

cout << smallest << ' ' << largest;

or you could write the loop as

for (double element : w) {
if (element < smallest) {
smallest = element;
}
else if (element > largest) {
largest = element;
}
} // end for
```

Computer Science & Information Technology

You might also like to view...

Schemas normally use the ______ extension.

a) .shm b) .sch c) .xsd d) .schema

Computer Science & Information Technology

You should never ask a question if there is ____ possible answer(s) or outcome(s).

A. an unknown set of B. a known set of C. two or fewer D. only one

Computer Science & Information Technology

Multivalued fields are created using the Input Mask Wizard

Indicate whether the statement is true or false

Computer Science & Information Technology

Describe how PowerPivot can be used to create a simple dashboard and discuss a few simple ways to enhance the value of a dashboard

What will be an ideal response?

Computer Science & Information Technology