All language subtitles for 3. Arrays - Initialization

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,480 --> 00:00:03,360 Now let's learn how to initialize an array. 2 00:00:03,930 --> 00:00:06,750 So by now we know how to declare an array. 3 00:00:06,840 --> 00:00:10,740 And now I want us to talk about how to initialize it. 4 00:00:10,860 --> 00:00:17,100 And that simply means how can we declare and assign some content to the array at the same time? 5 00:00:17,220 --> 00:00:25,230 So if I'm making you some comparison and I talk about how we use the initialize some individual variables, 6 00:00:25,590 --> 00:00:29,850 we just use to declare it and assign a value right after it. 7 00:00:29,940 --> 00:00:37,080 So, for example, we used in Nomikos to five double B equals to seven point three and Char C equals 8 00:00:37,080 --> 00:00:39,600 two, the lower case H. 9 00:00:39,930 --> 00:00:43,980 So it's very similar to how we declare that these variables. 10 00:00:44,010 --> 00:00:47,490 But now we just use in the declaration line. 11 00:00:47,550 --> 00:00:57,360 Also some assignment and we initialize some value for each of these variables and to initialize an array. 12 00:00:57,390 --> 00:01:05,250 We can simply use curly brackets right after the assignment to specify the values that each element 13 00:01:05,310 --> 00:01:07,110 of the array will have. 14 00:01:07,200 --> 00:01:13,560 So if we take a further look at the initialization of arrays, we can see that we can initialize an 15 00:01:13,560 --> 00:01:23,310 array of integers just by specifying its type, like liquidy Clearlake right into a ARAA with the size 16 00:01:23,370 --> 00:01:24,180 of three. 17 00:01:24,330 --> 00:01:30,240 And then in the curly brackets, in the curly brackets, we initialize the array with three integers 18 00:01:30,300 --> 00:01:32,850 so that the first one will be five. 19 00:01:33,090 --> 00:01:34,650 The second one will be seven. 20 00:01:35,040 --> 00:01:37,380 And the last element will be ten. 21 00:01:37,470 --> 00:01:40,510 So nothing complicated for each element in the array. 22 00:01:40,530 --> 00:01:43,260 Here we specified what will be its value. 23 00:01:43,500 --> 00:01:44,090 The first one. 24 00:01:44,100 --> 00:01:45,600 The second and the third. 25 00:01:45,930 --> 00:01:49,040 And the thing we can do also for a floating point arrays. 26 00:01:49,410 --> 00:01:51,930 First of all, will specify the type of the array. 27 00:01:51,960 --> 00:01:59,670 Then its name, the number of filaments within and venerable use some assignment in these curly brackets. 28 00:01:59,790 --> 00:02:02,790 So we created an array with three values. 29 00:02:02,820 --> 00:02:03,090 Right. 30 00:02:03,100 --> 00:02:05,490 I'm just using three just for convenience. 31 00:02:05,490 --> 00:02:08,230 See, it does not have to be only three. 32 00:02:08,230 --> 00:02:11,220 It can be one, two, five, 10 or whatever. 33 00:02:11,470 --> 00:02:17,490 And now we can say that we can also create an array of chars, an array of characters. 34 00:02:18,000 --> 00:02:22,980 So, for example, if we want to create an array of characters that will hold your name. 35 00:02:22,980 --> 00:02:24,450 Let's say your name is Mike. 36 00:02:24,750 --> 00:02:27,270 So you create a characters array. 37 00:02:27,720 --> 00:02:33,870 For example, in this case, we have four elements and each element will hold a character. 38 00:02:33,960 --> 00:02:36,360 So the first element will hold the letter. 39 00:02:36,450 --> 00:02:38,130 Am I k? 40 00:02:38,400 --> 00:02:41,700 And then the last element will hold the letter E.. 41 00:02:41,850 --> 00:02:43,100 So I hope that's clear. 42 00:02:43,110 --> 00:02:50,580 And basically now if you are my you know how to initialize your name using an array and you can also 43 00:02:50,580 --> 00:02:54,870 try to do it using your own name to see if it works. 44 00:02:54,960 --> 00:03:01,980 So that's basically one way to initialize an array where we specify the values for all the elements 45 00:03:01,980 --> 00:03:02,700 in the array. 46 00:03:02,760 --> 00:03:07,800 So we specify that the arrays of size three, four or whatsoever. 47 00:03:07,830 --> 00:03:13,230 But we also are we also must specify the value for each element. 48 00:03:13,260 --> 00:03:19,980 Like we've seen this exam bond, the results are another way, which in some cases may be much more 49 00:03:19,980 --> 00:03:21,240 convenient to use. 50 00:03:21,330 --> 00:03:25,730 So let's see if you wanted to initialize an array with just zeros. 51 00:03:25,910 --> 00:03:33,090 Then it wouldn't be just a waste of time to specify in a ARAA in some size, let's say 20, and then 52 00:03:33,090 --> 00:03:35,370 using the curly brackets 20 times. 53 00:03:35,400 --> 00:03:38,220 Use the integer as zero. 54 00:03:38,310 --> 00:03:42,470 So something easier would be just to use the zero in these curly brackets. 55 00:03:42,490 --> 00:03:48,930 And this will specify and set all the elements of the array or the five elements to be equal to zero. 56 00:03:49,050 --> 00:03:49,500 All right. 57 00:03:49,530 --> 00:03:53,610 That's that's I guess that's much easier to use. 58 00:03:54,030 --> 00:04:03,050 And when probably there are going to be a lot of examples when you will want to set all the values of 59 00:04:03,050 --> 00:04:09,120 a given a rate to zero because it's used the logic, the counter arrays problems. 60 00:04:09,210 --> 00:04:12,390 So we will see two guests in one of our challenges. 61 00:04:12,420 --> 00:04:22,890 Even in this course, we'll see how how we can count the number of times each digit appears in a number 62 00:04:22,950 --> 00:04:27,560 or maybe two, count the number of flatterers appearing at a sentence. 63 00:04:27,580 --> 00:04:31,710 And that's exactly when we are going to use these Kountouris arrays. 64 00:04:32,430 --> 00:04:38,550 And that's why you must be capable of initializing them correctly. 65 00:04:38,940 --> 00:04:45,000 And also, if you would like, for example, to specify just the couple of first variables, san, to 66 00:04:45,030 --> 00:04:46,890 nullify all the remaining. 67 00:04:47,220 --> 00:04:49,020 You could also do something like this. 68 00:04:49,140 --> 00:04:52,620 So here we can see that the arrays of size five. 69 00:04:52,650 --> 00:04:58,260 But we just specify the first three elements, which will be one and two. 70 00:04:58,740 --> 00:04:59,740 And this will set. 71 00:04:59,960 --> 00:05:05,630 First element to be won and the second element to be two and the remaining elements of the array will 72 00:05:05,630 --> 00:05:06,740 be zero. 73 00:05:07,040 --> 00:05:15,140 So that's another way this sort of auto completion way off in each initializing the arrays. 74 00:05:15,230 --> 00:05:19,470 So to summarize, there are mainly two approaches to you. 75 00:05:19,730 --> 00:05:20,720 Initialize an array. 76 00:05:21,020 --> 00:05:27,110 Either you specify the value for each of the elements of a given array based on the size of the array. 77 00:05:27,620 --> 00:05:34,490 Or you can do this auto completion approach where you specify just a couple of elements and then the 78 00:05:34,490 --> 00:05:38,510 rest of the elements of the array are going to be zero. 79 00:05:38,630 --> 00:05:40,220 So thank you guys for watching. 80 00:05:40,250 --> 00:05:44,930 Now you know how to declare of an array and how to initialize it. 81 00:05:45,230 --> 00:05:48,680 And you are ready to move on to the next video. 7828

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.