Inroduction of Arrays Introduction to Arrays An array is a variable capable of s
ID: 3762285 • Letter: I
Question
Inroduction of Arrays
Introduction to Arrays An array is a variable capable of storing multiple values. When we declare an array we tell the compiler how many values we want the array to hold. We also tell the compiler what type of values the array can store. All of the values in an array must be of the same type. Here is a declaration of an array called numlist that will be used to store 8 integers 1. int numlist[8] I/ declare int array that can store 8 values If we wish to fill the array numlist with the integers typed from the keyboard, you can use a for loop. Here is a for loop that will allow you to enter 8 values from the keyboard and will store them in the array numlist. Notice that we have used the variable i as an index for array numlist.Explanation / Answer
#include<iostream.h>
using namespace std;
int main()
{int numlist[8],i;
for(i<0;i<8;i++)
{cout<<" enter value #"<<i+1<<":";
cin>>numlist[i];
}
for(i=7;i>=0;i--) // TO PRINT THE ARRAY LIST IN REVERSE ORDER FROM 8TH ELEMENT TO 1ST ELEMENT
{ cout<<"value #"<<i+1<<":";
cout<<numlist[i];
}