90.4k views
5 votes
Dеclarе and allocatе mеmory (on thе hеap) for a onе-dimеnsional array of 256 doublеs namеd pricеs

User Dpkp
by
5.9k points

1 Answer

4 votes

Answer:

double *prices=new double [256];

Step-by-step explanation:

To allocate memory on heap we use new keyword.In the above statement an array name prices is declared and the memory allocated to it is on the heap memory.

First look at double * prices.It is a pointer this pointer is created on the stack memory which holds starting address of the array present on the heap memory of size 256..

User Andraz
by
5.7k points