Print one dimensional array - C++ Program

Q. Write a C++ program to print one dimensional array.

Answer:

Following program is displaying and printing one dimensional array.

#include<iostream>
using namespace std;
int main()
{
        int arr[50], num, i;
        cout<<"\n How Many Elements You Want to Store into an Array? \n";
        cin>>num;
        cout<<"\n Enter "<<num<<" Elements to Store into an Array : \n";
        for(i=0; i<num; i++)
        {
                cin>>arr[i];
        }
        cout<<"\n The Elements in the Array are : \n";
        for(i=0; i<num; i++)
        {
                cout<<arr[i]<<"\t";
        }
        return 0;
}


Output:

one dimensional