Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Now let's learn how to initialize an array.
So by now we know how to declare an array.
And now I want us to talk about how to initialize it.
And that simply means how can we declare and assign some content to the array at the same time?
So if I'm making you some comparison and I talk about how we use the initialize some individual variables,
we just use to declare it and assign a value right after it.
So, for example, we used in Nomikos to five double B equals to seven point three and Char C equals
two, the lower case H.
So it's very similar to how we declare that these variables.
But now we just use in the declaration line.
Also some assignment and we initialize some value for each of these variables and to initialize an array.
We can simply use curly brackets right after the assignment to specify the values that each element
of the array will have.
So if we take a further look at the initialization of arrays, we can see that we can initialize an
array of integers just by specifying its type, like liquidy Clearlake right into a ARAA with the size
of three.
And then in the curly brackets, in the curly brackets, we initialize the array with three integers
so that the first one will be five.
The second one will be seven.
And the last element will be ten.
So nothing complicated for each element in the array.
Here we specified what will be its value.
The first one.
The second and the third.
And the thing we can do also for a floating point arrays.
First of all, will specify the type of the array.
Then its name, the number of filaments within and venerable use some assignment in these curly brackets.
So we created an array with three values.
Right.
I'm just using three just for convenience.
See, it does not have to be only three.
It can be one, two, five, 10 or whatever.
And now we can say that we can also create an array of chars, an array of characters.
So, for example, if we want to create an array of characters that will hold your name.
Let's say your name is Mike.
So you create a characters array.
For example, in this case, we have four elements and each element will hold a character.
So the first element will hold the letter.
Am I k?
And then the last element will hold the letter E..
So I hope that's clear.
And basically now if you are my you know how to initialize your name using an array and you can also
try to do it using your own name to see if it works.
So that's basically one way to initialize an array where we specify the values for all the elements
in the array.
So we specify that the arrays of size three, four or whatsoever.
But we also are we also must specify the value for each element.
Like we've seen this exam bond, the results are another way, which in some cases may be much more
convenient to use.
So let's see if you wanted to initialize an array with just zeros.
Then it wouldn't be just a waste of time to specify in a ARAA in some size, let's say 20, and then
using the curly brackets 20 times.
Use the integer as zero.
So something easier would be just to use the zero in these curly brackets.
And this will specify and set all the elements of the array or the five elements to be equal to zero.
All right.
That's that's I guess that's much easier to use.
And when probably there are going to be a lot of examples when you will want to set all the values of
a given a rate to zero because it's used the logic, the counter arrays problems.
So we will see two guests in one of our challenges.
Even in this course, we'll see how how we can count the number of times each digit appears in a number
or maybe two, count the number of flatterers appearing at a sentence.
And that's exactly when we are going to use these Kountouris arrays.
And that's why you must be capable of initializing them correctly.
And also, if you would like, for example, to specify just the couple of first variables, san, to
nullify all the remaining.
You could also do something like this.
So here we can see that the arrays of size five.
But we just specify the first three elements, which will be one and two.
And this will set.
First element to be won and the second element to be two and the remaining elements of the array will
be zero.
So that's another way this sort of auto completion way off in each initializing the arrays.
So to summarize, there are mainly two approaches to you.
Initialize an array.
Either you specify the value for each of the elements of a given array based on the size of the array.
Or you can do this auto completion approach where you specify just a couple of elements and then the
rest of the elements of the array are going to be zero.
So thank you guys for watching.
Now you know how to declare of an array and how to initialize it.
And you are ready to move on to the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.