All language subtitles for 2. Arrays – Declaration

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
hu Hungarian Download
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,300 --> 00:00:01,650 What is going on, guys? 2 00:00:01,680 --> 00:00:02,700 My name is Vlad. 3 00:00:02,790 --> 00:00:07,670 And now we are going to talk about how to declare and how to initialize arrays. 4 00:00:07,920 --> 00:00:14,250 So when we talk about data types, we usually should start with the following question, how we should 5 00:00:14,370 --> 00:00:15,080 declare it. 6 00:00:15,150 --> 00:00:16,950 How should we declare an array? 7 00:00:17,100 --> 00:00:21,840 This simply means how can we specify the creation of something new? 8 00:00:21,870 --> 00:00:29,100 How can we create a new array so similar to working with variables of different types which you have 9 00:00:29,100 --> 00:00:32,730 seen how that's being done in most of the previous chapters? 10 00:00:33,300 --> 00:00:41,190 The first thing that we need to do before using them is to specify that these variables do exist, that 11 00:00:41,190 --> 00:00:45,030 someone has created them for us or we created them. 12 00:00:45,030 --> 00:00:45,390 Right. 13 00:00:45,900 --> 00:00:47,970 So it's also the same for a race. 14 00:00:48,210 --> 00:00:52,230 The first thing that we have to do to work with the race is to declare them. 15 00:00:52,560 --> 00:00:57,720 Now, once you declare that you are ready to do different types of operations, including accessing 16 00:00:57,720 --> 00:01:03,350 different elements of the array, assigning values to elements, input output and so on. 17 00:01:03,950 --> 00:01:04,350 Okay. 18 00:01:04,560 --> 00:01:06,380 So I hope that's clear. 19 00:01:06,390 --> 00:01:11,520 And now let's take a look at the declaration see index in our C programming language. 20 00:01:11,970 --> 00:01:18,360 So we said that for the simple variables we've talked about so far, we used to declare them like this 21 00:01:18,740 --> 00:01:21,660 with, first of all, specify the type of the variable. 22 00:01:21,720 --> 00:01:23,720 And then we specified the names of four. 23 00:01:23,820 --> 00:01:30,880 In this example, we used int grade and we know that grade is the name of the variable and end is a 24 00:01:30,920 --> 00:01:34,170 sexually it's type, the type of the variable integer. 25 00:01:34,260 --> 00:01:40,890 So that's a simple variable symbol box with the name grade, which is simply used to hold your grade 26 00:01:41,100 --> 00:01:44,820 when your last exam and it will be of an integer type. 27 00:01:44,870 --> 00:01:45,060 Okay. 28 00:01:45,780 --> 00:01:49,290 And another example may be like double salary. 29 00:01:49,290 --> 00:01:49,680 Right. 30 00:01:49,800 --> 00:01:57,270 Some variable to some simple variable to hold your salary and it's of a floating point type B double 31 00:01:57,270 --> 00:01:57,580 type. 32 00:01:57,720 --> 00:02:04,690 We also have if we want char, my char and other variable to store one character. 33 00:02:04,950 --> 00:02:12,570 And we can specify a lot of other examples here for the declaration of different variables of different 34 00:02:12,570 --> 00:02:21,720 names and of different types which specify how you create and basically how you declare a simple variable 35 00:02:21,720 --> 00:02:22,680 is simple variable. 36 00:02:22,680 --> 00:02:32,780 It's just my my analogy to to let you understand it in more with more ease on how to understand arrays. 37 00:02:32,850 --> 00:02:33,180 Okay. 38 00:02:33,390 --> 00:02:38,220 So we define different simple variables with different names and different types. 39 00:02:38,360 --> 00:02:39,000 That's it. 40 00:02:39,450 --> 00:02:41,760 And that's basically what we've learned so far. 41 00:02:41,900 --> 00:02:50,100 And now we're ready to proceed and to talk about how the declaration of arrays looks like in our language. 42 00:02:50,220 --> 00:02:56,880 So the first thing to bear in mind is the fact that we are creating some sort of collection of elements. 43 00:02:57,270 --> 00:03:03,630 And this collection of elements is going to reside under one roof called an array. 44 00:03:03,720 --> 00:03:09,430 So similarly to creating a great variable, we are just using INT. 45 00:03:10,230 --> 00:03:18,150 We will create an array of grades that will hold a collection of grades and we do so like the following. 46 00:03:18,270 --> 00:03:20,880 First of all, we specify the type end. 47 00:03:21,210 --> 00:03:25,380 Then we use the name of this collection of this array. 48 00:03:25,860 --> 00:03:29,400 And in the square brackets we specify its size. 49 00:03:29,430 --> 00:03:32,940 Meaning how many variables. 50 00:03:33,630 --> 00:03:34,110 Great. 51 00:03:34,200 --> 00:03:37,780 How many grades we want to hold in these collection. 52 00:03:37,950 --> 00:03:41,880 So the name of this array we've just created is grades. 53 00:03:42,060 --> 00:03:44,250 This array has five elements. 54 00:03:44,280 --> 00:03:51,390 We can see the size of the array in these square brackets and the type of each of the elements, the 55 00:03:51,390 --> 00:03:57,930 type of every grade is an integer similar to what we've created, just singular, a simple variable. 56 00:03:58,110 --> 00:03:58,830 Is that clear? 57 00:03:58,830 --> 00:03:59,750 So far enough. 58 00:03:59,850 --> 00:04:00,870 Complicated, right. 59 00:04:00,900 --> 00:04:01,710 One roof. 60 00:04:01,740 --> 00:04:07,530 And under these collection, under this roof, we have a collecting multiple elements. 61 00:04:07,560 --> 00:04:09,480 We may have multiple grades. 62 00:04:09,630 --> 00:04:16,160 So also, please note that all the five elements we've been visa array are, first of all, aren't initialized. 63 00:04:16,230 --> 00:04:20,040 You created the end of the array, but you didn't initialize anything. 64 00:04:20,220 --> 00:04:22,050 Just like with simple variables. 65 00:04:22,080 --> 00:04:27,150 If we didn't initialize them, then they are going to be on initialized. 66 00:04:27,360 --> 00:04:29,520 We didn't sign any value to them. 67 00:04:29,790 --> 00:04:34,720 So once again, here in the square racket's, we have the size of the array here. 68 00:04:34,950 --> 00:04:40,770 We can see the type of each of the elements within this collection with the inverse array. 69 00:04:40,920 --> 00:04:44,790 And here we can see actually the elements inside of this array. 70 00:04:44,860 --> 00:04:51,060 Okay, first of all, if we did not assign any value, then they are going to be on initialized. 71 00:04:51,180 --> 00:04:55,080 So we just created our array. 72 00:04:55,110 --> 00:04:58,290 And now we want to see what we can do next with it. 73 00:04:58,380 --> 00:04:59,880 You will be able to read. 74 00:04:59,980 --> 00:05:01,300 Data from the user. 75 00:05:01,390 --> 00:05:07,120 For example, if the user will have five grades, we will be able to read these grades and store them 76 00:05:07,120 --> 00:05:11,640 inside of each of these elements in the collection, in this array, or maybe will. 77 00:05:11,800 --> 00:05:20,080 We will be able to assign different values based on our needs or to print the results and so on and 78 00:05:20,080 --> 00:05:20,620 so forth. 79 00:05:20,950 --> 00:05:27,700 So once again, quickly to summarize everything up, the necessary steps to declare an array are first 80 00:05:27,700 --> 00:05:33,460 of all, you specify the type of the elements you would like the array to HALD, whether the type of 81 00:05:33,460 --> 00:05:39,730 the elements should be an integer like we've used in the previous example, or even may be offering 82 00:05:39,910 --> 00:05:42,490 a double type, B char type and so on. 83 00:05:42,730 --> 00:05:48,610 Then you should specify the name of the array, some appropriate unique name which will allow us to 84 00:05:48,610 --> 00:05:52,780 white densify this particular array over some other array. 85 00:05:52,810 --> 00:05:53,070 Right. 86 00:05:53,080 --> 00:05:54,910 Which has a different name. 87 00:05:55,000 --> 00:05:58,510 We should be able to distinguish between different arrays. 88 00:05:58,810 --> 00:06:02,890 So that's why we should have a unique name for each of them. 89 00:06:03,160 --> 00:06:04,030 Makes sense, right. 90 00:06:04,150 --> 00:06:08,380 And lastly, what we want to do is to specify the lengths of the array. 91 00:06:09,370 --> 00:06:12,580 And this could be done by using the square brackets. 92 00:06:12,670 --> 00:06:18,340 So the length of the array simply says how many elements of the specified type. 93 00:06:18,370 --> 00:06:19,250 We've defined it. 94 00:06:19,270 --> 00:06:23,590 Step one are going to be in this particular array. 95 00:06:23,860 --> 00:06:28,120 Please note that the size of the array must be constant. 96 00:06:28,300 --> 00:06:32,610 And it's very important that you define the size of your array as constant. 97 00:06:32,740 --> 00:06:38,230 And that's important because if you don't do so, then the program is simply not going to work. 98 00:06:38,530 --> 00:06:40,180 It's not going to compile. 99 00:06:40,330 --> 00:06:45,010 And specifying the size of the array is constant, is done mainly. 100 00:06:45,030 --> 00:06:51,610 So the computer will know at the compilation phase how much memory we'll need to allocate for the whole 101 00:06:51,610 --> 00:06:52,000 array. 102 00:06:52,270 --> 00:06:57,410 Since the arrays stored as a sequence of fellowman, just one element after the other. 103 00:06:57,820 --> 00:07:01,110 That's actually how it's stored in the memory of the computer. 104 00:07:01,300 --> 00:07:03,780 It's simply a sequence of elements. 105 00:07:04,660 --> 00:07:12,550 So basically you've got the idea and we can say that these were the steps for declaring arrays. 106 00:07:12,700 --> 00:07:19,930 And now let's create another array which will be used to hold salaries off employees in a company. 107 00:07:20,080 --> 00:07:23,140 So now we've created an array of salaries. 108 00:07:23,200 --> 00:07:28,420 And each element in this array is going to be off a floating coin type. 109 00:07:28,840 --> 00:07:32,900 And the number of elements in this array is 10. 110 00:07:33,130 --> 00:07:35,550 And basically, that's makes sense, right? 111 00:07:35,590 --> 00:07:41,740 Because the type of the salary is probably not going to be of an integer type, but rather it would 112 00:07:41,740 --> 00:07:44,830 be of a double type or free flow type. 113 00:07:44,980 --> 00:07:50,530 So that's why we created an array of a floating point type of values. 114 00:07:50,560 --> 00:07:56,350 And probably in a company there is more than just one employee. 115 00:07:56,470 --> 00:07:58,390 So, for example, 10 employees. 116 00:07:58,390 --> 00:08:03,040 And we therefore created an array of size 10. 117 00:08:03,310 --> 00:08:08,500 And you can also define an array of characters by using char my array, let's say. 118 00:08:08,530 --> 00:08:12,140 This way of a size four hundred. 119 00:08:12,280 --> 00:08:13,210 Simple as that. 120 00:08:13,600 --> 00:08:19,780 Just know that once you've decided on the type of the array, it will be the type of all the arrays 121 00:08:20,080 --> 00:08:20,860 elements. 122 00:08:21,040 --> 00:08:24,350 You can't let the first two to be of type end. 123 00:08:24,430 --> 00:08:26,940 And the next three are to be of type double. 124 00:08:26,950 --> 00:08:30,130 And the last five let's say, to be even of type char. 125 00:08:30,220 --> 00:08:31,270 That's not possible. 126 00:08:31,390 --> 00:08:38,380 Once you've decided on the type of the array, all the elements of the array will have the same particular 127 00:08:38,380 --> 00:08:38,740 type. 128 00:08:38,860 --> 00:08:44,530 So in the first example, we can see here with the salaries, all the elements within this array, within 129 00:08:44,850 --> 00:08:50,180 this collection are going to be of a floating point of a double type. 130 00:08:50,680 --> 00:08:56,920 And in the second example were where we created an array of characters of size of a one hundredth size. 131 00:08:57,790 --> 00:09:01,540 All the elements are going to be of a character type. 132 00:09:01,660 --> 00:09:02,740 So I hope that's clear. 133 00:09:02,770 --> 00:09:09,580 Guys, I hope you understand now how to create an array, how to specify its size, its name and its 134 00:09:09,580 --> 00:09:10,070 type. 135 00:09:10,660 --> 00:09:17,410 And you are ready to move on the next video where we are going to talk about how to initialize an array. 136 00:09:17,890 --> 00:09:19,120 So I'll see you there. 13135

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