Hello, I am having trouble with this homework question for c++. Pointer Arithmetic Write function for given main function: int* return_an_array(int n) which takes an integer n and returns a pointer to...


Hello, I am having trouble with this homework question for c++.


Pointer Arithmetic


Write function for given main function:


int* return_an_array(int n)


which takes an integer n and returns a pointer to an array (allocated off of the heap in the function) containing the digits of n in the appropriate positions. If n = 0 return 0 (which is the “null” pointer). Recall an array name is just a pointer to the first element of the array.


Implement a print function for an array using pointer arithmetic.




Use following main() to test your class.(

DO NOT change the int main provided)

int main() {
int *a = return_an_array(56789); //array of size 5
print(a,5); // print 5 6 7 8 9
delete []a;
return 0;
}



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here