Create a Program which creates a dynamic array and initialize at the run time by the user. Add Two Functions(Using Pointer) Print Array Reverse Print

Problem: 

Create a Program which creates a dynamic array and initialize at the run time by the user. 

Add Two Functions(Using Pointer) 

  • Print Array 

  • Reverse Print

#include<iostream>
#include<conio.h>
using namespace std;
void print_array(int *arr)
{
    for(int i=0;i<10;i++){
        cout<<arr[i]<<"\t";
    }
    cout<<endl;
}
void reverse_print(int *arr)
{
    for(int i=10-1;i>=0;i--){
        cout<<arr[i]<<"\t";
    }
    cout<<endl;
}
int main()
{
    int *array;
    array = new int[10];
    cout<<"Please enter elements of array: ";
    for (int i = 0; i < 10; i++) {
        cin>>array[i];
    }
    print_array(array);
    reverse_print(array);
}

Comments