C Language – arrays (vectors)

C Language – arrays (vectors)


c Language

 

 

What are arrays?

 

Think of a train with many cars, each car will contain an element.

 

In mathematical terms, for example, an array could be a numeric set.

 

Arrays can have a fixed size and variable size. Since we are at the beginning of this topic, I will talk about fixed-size arrays.

 

Like any variable to declare an array, you first need to indicate the type of data.

 

If you declare an array of integers “in the train cars you can only put whole numbers”.

 

C Language

 

So after indicating the type of data for the array you have to give a name and in square brackets a dimension that indicates, in simple words the train cars.

 

EX:

 

int vector [10]

 

What can the carriers serve? Well if we have to create a code where we need to save many numbers or many characters, we can not declare many variables, by simply declaring an array we have avoided declaring all these variables.

 

On the arrays it is possible to do mathematical operations, but we must indicate on which wagons we must operate.

 

Now I put a picture with an example where I fill two vectors of numbers, and I create a third vector where in the first train of the third train I will go to put the sum of the first wagon of the first array + the first wagon of the second array.

 

C Language

 

These are one-dimensional arrays later on I’ll talk about two-dimensional arrays (there are arrays with more dimensions but the ones that are mostly used are two-dimensional and one-dimensional).

 

Arrays are a fundamental part of C language. So if you want to start programming perfectly, look for internet exercises on C language vectors.

If you are familiar with the carriers you are at a good point to start doing the most serious things.

 

 

Stay Tuned! 


Giuseppe

Salve, sono un ragazzo di 25 anni, iscritto alla facoltà di informatica, appassionato di programmazione e delle nuove news tecnologiche in ambito informatico.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu