Suppose that we use dynamic memory allocation to create an a
Suppose that we use dynamic memory allocation to create an array of ten floating-point
values at run-time.
double* ptr = new double[10];
(a) Provide a C++ statement to assign the fifth item the value -8.7.
(b) What is signicant about the memory address ptr + 10?
Solution
a) *(ptr+4)= -8.7
b) the memory address ptr +10 is invalid because the 10 address are from ptr to ptr+9
![Suppose that we use dynamic memory allocation to create an array of ten floating-point values at run-time. double* ptr = new double[10]; (a) Provide a C++ state Suppose that we use dynamic memory allocation to create an array of ten floating-point values at run-time. double* ptr = new double[10]; (a) Provide a C++ state](/WebImages/26/suppose-that-we-use-dynamic-memory-allocation-to-create-an-a-1070196-1761560482-0.webp)