All language subtitles for 3. Arrays - Initialization

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

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.