All language subtitles for 9. Using a define

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,270 --> 00:00:01,750 What is going on, guys? 2 00:00:01,770 --> 00:00:07,470 And now that you're familiar with the race syntax, I want you to take a look at one or four previous 3 00:00:07,470 --> 00:00:14,040 challenges where we had to read from the user a seven digits of his phone number. 4 00:00:14,160 --> 00:00:21,660 And then once we've done reading these numbers, we had to find out the maximum value or index, whatever 5 00:00:21,660 --> 00:00:22,260 it was. 6 00:00:22,380 --> 00:00:27,480 So we simply used some for a loop, for a loop to iterate over these seven numbers. 7 00:00:27,810 --> 00:00:29,340 And that was great. 8 00:00:29,370 --> 00:00:30,940 We found everything we needed. 9 00:00:31,200 --> 00:00:39,240 But what will happen if your phone numbers, if your phone number happens to change from seven to, 10 00:00:39,270 --> 00:00:40,430 let's say, eight? 11 00:00:41,070 --> 00:00:46,590 So instead of these seven digits, it was previously, now it's going to be eight digits. 12 00:00:46,920 --> 00:00:49,650 Something like that can definitely happen. 13 00:00:49,650 --> 00:00:50,040 Right. 14 00:00:50,130 --> 00:00:52,140 And that's not a big deal. 15 00:00:52,140 --> 00:00:59,910 But still, you want your program to support such changes in the future that these are things that may 16 00:00:59,910 --> 00:01:09,360 happen and you want your program to be able to find the maximum value or the maximum index of that maximum 17 00:01:09,360 --> 00:01:13,980 value, even if changes like this happen. 18 00:01:14,670 --> 00:01:21,630 So if that's the case, basically what you will have to do in this case is to go over all the loops, 19 00:01:22,080 --> 00:01:29,580 find all the places where you've used the size of the array, which was 17, the previous example, 20 00:01:30,000 --> 00:01:34,650 and simply change these values, one after the other to be eight. 21 00:01:34,860 --> 00:01:40,530 So you would need to change all the places that you have the number of seven to eight. 22 00:01:40,950 --> 00:01:45,510 And that's not so complicated if the program is small like this one. 23 00:01:45,900 --> 00:01:53,460 But what will happen if your program will be hundreds and hundreds and thousands of lines of code? 24 00:01:53,790 --> 00:01:56,880 Will you go and change every line? 25 00:01:57,000 --> 00:01:58,590 Just one by one. 26 00:01:58,740 --> 00:02:04,230 I mean, that's that's totally will be same to do such a thing. 27 00:02:04,330 --> 00:02:07,890 And what will happen if you missed just a couple of places? 28 00:02:07,920 --> 00:02:10,500 You will you may have a lot of bugs. 29 00:02:10,890 --> 00:02:15,150 So that's exactly when the define comes to our aid. 30 00:02:15,600 --> 00:02:17,580 So let's come here, define. 31 00:02:18,300 --> 00:02:26,310 And basically what it allows us to do is simply to define the size of the array in just one place in 32 00:02:26,310 --> 00:02:27,060 our code. 33 00:02:27,510 --> 00:02:33,750 So then instead of using the number seven, which is the size of the array, we used it here at every 34 00:02:33,750 --> 00:02:39,780 point of our program instead of using seven here, here and here and so on, you will be able to use 35 00:02:39,780 --> 00:02:48,330 just one defined value, meaning that whenever the size of the array changes, we will need to change 36 00:02:48,330 --> 00:02:51,750 it only in one single place in our code. 37 00:02:52,230 --> 00:02:56,130 And that will work like Char just changing it in one place. 38 00:02:56,160 --> 00:02:59,490 And it will change everything in the code. 39 00:02:59,580 --> 00:03:00,990 Everything in the program. 40 00:03:01,470 --> 00:03:03,460 So let's introduce the define. 41 00:03:04,290 --> 00:03:08,670 And we can see we can actually see how it's written here. 42 00:03:08,790 --> 00:03:11,220 And these first line we first of all. 43 00:03:11,220 --> 00:03:11,670 Right. 44 00:03:11,700 --> 00:03:16,950 The define the defined word and then we specify the constant value name. 45 00:03:17,310 --> 00:03:21,220 So the name here is size in a right after war. 46 00:03:21,220 --> 00:03:29,720 And we specify the constant value that this given name, these size would have during all of our program. 47 00:03:29,850 --> 00:03:38,100 So this line this line simply means that whenever we will have, we will write these size, define size 48 00:03:38,100 --> 00:03:40,130 value in our program. 49 00:03:40,130 --> 00:03:45,060 It will be we will enter, as we've written here, just the value of seven in this example. 50 00:03:45,150 --> 00:03:48,390 And also here you can see then here and so on. 51 00:03:48,390 --> 00:03:54,270 Whenever you are going to write size, it's equivalent, as you've written, of the number of seven 52 00:03:54,270 --> 00:03:55,020 previously. 53 00:03:55,320 --> 00:03:58,580 And basically, if you wanted to change. 54 00:03:58,640 --> 00:03:59,070 All right. 55 00:03:59,100 --> 00:04:04,350 If we wanted to change right now from seven to eight, the array, these given array. 56 00:04:04,500 --> 00:04:07,230 We will do this just this line. 57 00:04:07,350 --> 00:04:09,550 This line will change instead of size. 58 00:04:09,770 --> 00:04:12,150 Then the value of it was previously seven. 59 00:04:12,450 --> 00:04:14,520 Now we will just change it to be eight. 60 00:04:14,850 --> 00:04:19,560 And it will reflect the changes during all of your programs. 61 00:04:19,560 --> 00:04:26,850 So you will not need to go line by line and change the value of of the array in the loop. 62 00:04:26,920 --> 00:04:29,850 Sand in the declaration phase and so on. 63 00:04:30,090 --> 00:04:39,030 And these translation of the word size to the constant value that you've defined it here happens before 64 00:04:39,030 --> 00:04:41,460 the compilation phase of the program. 65 00:04:41,670 --> 00:04:42,030 Okay. 66 00:04:42,420 --> 00:04:46,830 So that's something we will discuss in the more advanced courses. 67 00:04:47,110 --> 00:04:47,390 Nothing. 68 00:04:47,430 --> 00:04:50,910 This one just bear that in mind because it's important. 69 00:04:51,030 --> 00:04:53,280 And you may be asking why. 70 00:04:53,310 --> 00:04:55,270 Why should we even define size? 71 00:04:55,560 --> 00:04:59,590 This is a constant value and not just use something like in a. 72 00:05:00,030 --> 00:05:06,990 Incise and read the signs using scanner from the user and then defined in a ARAA in these given size 73 00:05:07,020 --> 00:05:11,250 that we read from the user because that's basically not going to work. 74 00:05:11,390 --> 00:05:15,810 This size variable that you will create is going to be a variable. 75 00:05:16,320 --> 00:05:22,440 And we know that a static array expects hearing he's square brackets. 76 00:05:22,440 --> 00:05:24,900 It expects a constant value. 77 00:05:24,960 --> 00:05:31,740 And by default, if you create an variable, a variable and then read from the user, this variable 78 00:05:31,740 --> 00:05:34,170 is going to be, well, variable. 79 00:05:34,320 --> 00:05:35,770 So that will not work. 80 00:05:35,820 --> 00:05:38,110 But you can try it and see what happens on your own. 81 00:05:38,140 --> 00:05:39,240 That's good practice. 82 00:05:39,570 --> 00:05:43,720 And although there is also another option to allocate dynamically. 83 00:05:44,100 --> 00:05:45,360 Which won't be static. 84 00:05:45,930 --> 00:05:52,380 You can allocate dynamically where you allocate an array of a given size that the user specifies at 85 00:05:52,380 --> 00:05:53,160 runtime. 86 00:05:53,580 --> 00:05:56,910 We're probably not going to talk about it also in these course. 87 00:05:56,940 --> 00:06:03,390 But that's important that you will also know that there is two there are two types of fair or four raise 88 00:06:03,390 --> 00:06:05,160 that you can allocate. 89 00:06:05,170 --> 00:06:09,180 One of one of them is the static approach, which you can see here. 90 00:06:09,600 --> 00:06:13,380 It's defined before before you run the program. 91 00:06:13,500 --> 00:06:16,530 And that's why you specified as a constant value. 92 00:06:16,650 --> 00:06:23,940 And there is also another dynamic approach that you can specify how much memory you want to allocate 93 00:06:24,150 --> 00:06:25,190 during Iran time. 94 00:06:25,890 --> 00:06:29,220 So we'll talk about it more in the advanced courses. 8839

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