Write a function which (normally) allocates new space for a double array. It should alter its pointer argument to point to the newly allocated space. The size of the array should be a second argument. If this argument is not a valid array size, allocate a single double instead of a whole array. An example call might be:

Respuesta :

Answer:

see explaination

Explanation:

void allocate(double *q,int size)

{

if(size<=0)

q = new double; //Allocates a single double

else

q = new double[size]; //Allocates an array of doubles

}

This function allocates new space for a double array. It alter its pointer argument to point to the newly allocated space.

ACCESS MORE