I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
#include <iostream>
#define MAX_SIZE 100 //Maximum size of the array
using namespace std;
int main()
{
int arr[MAX_SIZE]; //Declares sizr of array
int i, num;
cout<<"Enter size of array: ";
cin>>num;
cout<<"Enter "<<num<< " elements in the array :";
//Reads size & elements in array
for(i=0; i<num; i++)
{
cin>>arr[i];
}
//Prints all elements of array
cout<<"\nElements in array are: ";
for(i=0; i<num; i++)
{
cout<<arr[i]<<"\t";
}
return 0;
}
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
Result:
Enter size of array: 5
Enter 5 elements in the array :10
20
30
40
50
Elements in array are: 10 20 30 40 50
need an explanation for this answer? contact us directly to get an explanation for this answer