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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site