Monday, April 10, 2017

Navid Plus: C++ Part 44

Navid Plus: C++ Part 44: An array is used to process a collection of data all of which is of the same type, such as a list of numbers or a list of names. An array...

C++ Part 44

An array is used to process a collection of data all of which is of the same type, such as a list of numbers or a list of names.
An array behaves like a list of variables with a uniform naming mechanism that can be declared in a single line of simple code.
Declaring and Referencing Arrays
In C++, an array consisting of five variables of type int can be declared as follows:
int score[5];
This declaration is like declaring the following five variables to all be of type int:
score[0], score[1], score[2], score[3], score[4]
We will call them indexed variables, though they are also sometimes called subscripted variables or elements of the array. The number in square brackets
is called an index or a subscript.