For each of the following, write C++ statements that perform the specified task. Assume that double-precision, floating-point numbers are stored in eight bytes and that the starting address of the built-in array is at location 1002500 in memory. Each part of the exercise should use the re- sults of previous parts where appropriate.

a) Declare a built-in array of type double called numbers with 10 elements, and initialize the elements to the values 0.0, 1.1, 2.2, …, 9.9. Assume that the constant size has been defined as 10.
b) Declare a pointer nPtr that points to a variable of type double.
c) Use a for statement to display the elements of built-in array numbers using array sub- script notation. Display each number with one digit to the right of the decimal point.
d) Write two separate statements that each assign the starting address of built-in array num- bers to the pointer variable nPtr.
e) Use a for statement to display the elements of built-in array numbers using pointer/off- set notation with pointer nPtr.

```
a) double numbers[size]{0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9};
b) double* nPtr;
c) cout << fixed << showpoint << setprecision(1);
for (size_t i{0}; i < size; ++i) {
cout << numbers[i] << ' ';
}
d) nPtr = numbers;
nPtr = &numbers[0];
e) cout << fixed << showpoint << setprecision(1);
for (size_t j{0}; j < size; ++j) {
cout << *(nPtr + j) << ' ';
}
```

Computer Science & Information Technology

You might also like to view...

The area of a chart bounded by the axes.

A. data labels B. legend C. plot area

Computer Science & Information Technology

Output from a monitor is considered ________ copy because it is not tangible

Fill in the blank(s) with correct word

Computer Science & Information Technology