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) << ' ';
}
```
You might also like to view...
If there is an extra space to the left of the first line of the paragraph, it is referred to as a(n) ________ indent
Fill in the blank(s) with correct word
The Opacity slider is on the ____ panel.
A. Opacity B. Bitmap C. Transform D. Transparency
A control that is connected to a field in a table or query.
What will be an ideal response?
Which of the following is true?
A. In the CBIS environment, auditors gather evidence relating only to the contents of databases, not the reliability of the computer system. B. Conducting an audit is a systematic and logical process that applies to all forms of information systems. C. Substantive tests establish whether internal controls are functioning properly. D. IT auditors prepare the audit report if the system is computerized.