Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Question Write and test a function that is passed an array of n pointers to

ID: 3794529 • Letter: C

Question

C++ Question Write and test a function that is passed an array of n pointers to floats and returns a newly created array that contains those n float values. float* translate (float* p [ ], int n) C++ Question Write and test a function that is passed an array of n pointers to floats and returns a newly created array that contains those n float values. float* translate (float* p [ ], int n) C++ Question Write and test a function that is passed an array of n pointers to floats and returns a newly created array that contains those n float values. float* translate (float* p [ ], int n) C++ Question Write and test a function that is passed an array of n pointers to floats and returns a newly created array that contains those n float values. float* translate (float* p [ ], int n)

Explanation / Answer

// declare function

float* translate(float* p[], int n)

{

float* const a = new float[n];

//here a is pointing to the beginning of array and this pointer stored in a cannot be changed.

for ( int i=0; i<n; i++) // for n array elements

{

a[i] = *p[i]; // store the value at pointer address into array a

return a; // returning the array of float values stored in array a

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote