Write a program that uses a function called Output_Array_Info. Output_Array_Info Properties: Input Parameters: 1. A pointer to an integer called array_ptr. This will be used to point to an array of integers. 2. An integer that stores the size of the array.

Respuesta :

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

ACCESS MORE