Arrays usage in c++
#include<iostream>
using namespace std;
int main()
{
int n[ 10 ]; // n is an array of 10 integers
// initialize elements of array n to 0
for ( int i = 0; i < 10; i++ )
{
cout<<"Enter element number "<<i<<endl; //taking user input
cin>>n[ i ]; //storing the value in array
}
cout <<"\nElement"<<" = " <<"Value"<< endl;
// output each array element's value
for ( int j = 0; j < 10; j++ )
cout <<" "<< j <<" = "<< n[ j ] << endl;
} // end main
EmoticonEmoticon