top of page

arrangements

Many times in our programs you need to use more than one variable of the same type ( int, float, bool, char ) and this can get complicated because you have to give a name to each and declare them all; to avoid this kind of problem we can use the " arrangements ", they serve to declare a variable that can store many similar values ​​to a table, which we can read and write only indicating their " position " to the program. The way to declare an arrangement is as follows:

Where " size " is the number of spaces that we will have our variable to store information and numbers right, is that we initialize house space arrangement. Important! In order to read or write in the first space arrangement, we must remember that the positions of the values ​​in the array starting at the "place zero " so if we have an " array of 5 space positions  of" 0 to 4 "

//variable[0] it has the value of 4
//variable[0] it has the value of 9
//variable[0] it has the value of 3
//variable[0] it has the value of 6
//variable[0] it has the value of 1
Example 1:

In this example we will use the structure to make the horn touch different notes, use an array to tell the program the notes the speaker should touch:

bottom of page