How would I go about writing the loop for displaying the index 0,1,2 ... 9 for an array with 10 elements ?
here is the code; I know i need to use a for loop, but where and how do i write it ? i tried :
for(int index=0;index<20;index++)
cout index;
int main()
{
const int ARRAY_SIZE = 10; // Array size
int numbers[ARRAY_SIZE]; {10,20,30,40,50,60,70,80,90,100}
int count; // Loop counter variable
int index;
for(count=0;count < ARRAY_SIZE;count++)
cout >>numbers[count]; // writes the values in the elements.
cout<<"\t\t"<<setw(10)<<"Index"<<setw(20)<<"Content\n\n";
for(count=0;count < ARRAY_SIZE;count++)
for( index=0;index<20;index++)
cout<<"\t\t"<<setw(10)<<index<<setw(16)<<numbers[count] <<"\n\n";
return 0;
}
Thank you.