//How to traverse the array using C++.
#include<iostream.h>
#include<conio.h>
void main()
{
int i, k, data[50], n, lb, ub;
clrscr();
cout<<endl<<"Enter the number of elements in the array:";
cin>>n;
cout<<endl<<"Enter the value of "<<n<<" elements:";
for(i=0; i<n; i++)
{
cin>>data[i];
}
lb=0;
ub=n-1;
for(k=lb; k<=ub; k++)
{
cout<<endl<<k<<" element is "<<data[k];
}
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int i, k, data[50], n, lb, ub;
clrscr();
cout<<endl<<"Enter the number of elements in the array:";
cin>>n;
cout<<endl<<"Enter the value of "<<n<<" elements:";
for(i=0; i<n; i++)
{
cin>>data[i];
}
lb=0;
ub=n-1;
for(k=lb; k<=ub; k++)
{
cout<<endl<<k<<" element is "<<data[k];
}
getch();
}