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

a) Display the value of element 6 of character array f.
b) Input a value into element 4 of one-dimensional floating-point array b.
c) Initialize each of the 5 elements of one-dimensional integer array g to 8.
d) Total and print the elements of floating-point array c of 100 elements.
e) Copy array a into the first portion of array b. Assume double a[ 11 ], b[ 34 ];
f) Determine and print the smallest and largest values contained in 99-element floating-point array w.

a) ```
cout << f[ 6 ] << '\n';
```
b) ```
cin >> b[ 4 ];
```
c) ```
int g[ 5 ] = { 8, 8, 8, 8, 8 };
or int g[ 5 ];
for ( int j = 0; j < 5; j++ )
g[ j ] = 8;
```
d) ```
total = 0.0;
for ( int k = 0; k < 100; k++ )
{
total += c[ k ]; // assume total declared and initalized
cout << c[ k ] << '\n';
} // end for
```
e) ```
for ( int i = 0; i < 11; i++ )
b[ i ] = a[ i ];
```
f) ```
smallest = w[ 0 ];
largest = w[ 0 ];
// assume all variables declared and initialized
for ( int j = 1; j < 99; j++ )
{
if ( w[ j ] < smallest )
smallest = w[ j ];
else if ( w[ j ] > largest )
largest = w[ j ];
} // end for
cout << smallest << ' ' << largest;
```

Computer Science & Information Technology

You might also like to view...

A new employee has reported that print jobs are printing as garbled text. Which of the following is MOST likely the reason for this issue?

A. The printer needs a maintenance kit installed B. The network cable on the printer is unplugged C. The workstation has the incorrect drivers installed D. The employee does not have the proper permissions

Computer Science & Information Technology

What do some programmers use to organize and summarize the results of a problem analysis?

A. Low-Flo diagram B. IPO chart C. POI diagram D. Sequence-Seletion-Iteration chart

Computer Science & Information Technology