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 5print(a,5); // print 5 6 7 8 9delete []a;return 0;}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here