Hey there! This is that is about the creation and the usage of arrays in c++. Arrays are different numbers with the same type placed in separate spaces. It is like to fill drawers with information to use them after. This is used instead of declaring individual variables.

 

Let´s say you want the program to ask for 10 various numbers separately and then get the total of them, in this case you can use arrays. The only “disadvantage” of using an array is that you have to define the number of values to introduce.

Using arrays is easier than it sounds.

 

To understand its use, it is better to imagine them as boxes you are saving info into:

 

0

1

2

3

4

5

6

7

8

 

 

 

 

 

 

 

 

 

 

An array starts it´s count from the box number 0. Declaring an array is as easy as declaring some other thing. The structure of an array is like this:

 

type  nameofarray [number of spaces];

 

       An array can be any type just as a normal variable, but it is a arrangement of variables.

       You can choose whichever name you want for your array.

       The number in between the squared braces [ ] is to set the number of values introduced in the array.

       The number of spaces in the array has to be an integer because it is a whole unit space.

 

The elements of an array can be used to be introduced by the user of the program, or you can type them after declaring in between braces= { }.

 

Then when you want to use the values already stored inside an array, you have to simply type the nameofarray[ number of space of the value]. Be aware that the space number 0 counts as a space.

 

 

WATCH MY VIDEO https://youtu.be/XekmFL6VBwI

CC BY 4.0 #Mastery24 -Creation and use of arrays in C++ by Ricardo Newton is licensed under a Creative Commons Attribution 4.0 International License.