C++,please do it all
3. 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 12 integers: const int SIZE 12: int nurmist [SIZE]: declare int array that can store 12 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 12 values from the keyboard and store them in the array numlist. Notice that we have used the variable i as an index for array numlist. for (i m 0: i SIZE: i++) cout "Enter the next value: cin numuistlil: It might be easier for our user to keep up with different values that need to be entered if we display something more helpful than "Enter the next value: Since users typically number items in a list starting from 1, we w say "Enter value M1 when asking for numlist 101, "Enter value #2: when asking for num list [1], and so forth. Here is the improved version of the loop: for (i 0: i SIZE: i++) cout "Enter value i-1 cin numlistlil By asking for value #1, then value H2, etc., we are allowing our user to count in a more natural way than C++ forces us to count. That is the most confusing part of working with arrays. It is natural to think that an array of size 12 will keep 12 values, thus, assuming that the indices would be 1through 12. For an array of size 12, index 1 is avalid index, but index 12 is invalid and may cause a run-time error if it is used. The following program allows you to enter 12 integers from the keyboard and will store those values in array numlist