Answer:
C++ code explained below
Explanation:
Please note the below program has been tested on ubuntu 16.04 system and compiled using g++ compiler. This code will also work on other IDE's
-----------------------------------------------------------------------------------------------------------------------------------
Program:
-----------------------------------------------------------------------------------------------------------------------------------
//header files
#include<iostream>
//namespace
using namespace std;
//function defintion
void Output_Array_Info(int *array_ptr, int size)
{
//display all array elements
cout<<"Array elements are: "<<endl;
for(int i =0; i<size; i++)
{
cout<<*(array_ptr+i)<<endl;
}
//display address of each element
cout<<endl<<"memory address of each array elemnt is: "<<endl;
for(int i =0; i<size; i++)
{
cout<<array_ptr+i<<endl;
}
}
//start of main function
int main()
{
//pointer variables
int *pointer;
//an array
int numbers[] = { 5, 7, 9, 10, 12};
//pointer pointing to array
pointer = numbers;
//calculate the size of the array
int size = sizeof(numbers)/sizeof(int);
//call to function
Output_Array_Info(numbers, size);
return 0;
}
//end of the main program