All language subtitles for 7. isEven Function C Exercise

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,450 --> 00:00:01,690 What is going on, guys? 2 00:00:01,740 --> 00:00:11,040 And in this video, we are going to solve some exercise regarding functions and we will start with a 3 00:00:11,040 --> 00:00:17,310 very simple function that is called let's call this function is even so, that's the name of the function. 4 00:00:17,370 --> 00:00:17,850 All right. 5 00:00:17,860 --> 00:00:20,400 So that's the name of the function. 6 00:00:20,970 --> 00:00:27,420 And what you have to do is to simply implement it, first of all, to define its signature, then to 7 00:00:27,420 --> 00:00:30,000 write all of its implementation. 8 00:00:30,810 --> 00:00:34,890 And all these function basically does is simply receiving. 9 00:00:34,920 --> 00:00:42,450 OK, so this function will receive will receive an integer, some number of an integer, a type. 10 00:00:43,020 --> 00:00:53,130 And this will this function will will return one if this given number is even OK. 11 00:00:53,670 --> 00:01:00,060 Otherwise this function should return, these function should return. 12 00:01:00,070 --> 00:01:04,050 What you need to return should return zero. 13 00:01:04,200 --> 00:01:12,510 OK, so in case that it's all OK that the received number is odd, then in this case the function should 14 00:01:12,510 --> 00:01:15,100 return basically zero. 15 00:01:16,440 --> 00:01:17,010 Awesome. 16 00:01:17,040 --> 00:01:23,820 So now take a couple of moments and think about what should be the solution for this function. 17 00:01:24,000 --> 00:01:27,360 What should be should be its signature. 18 00:01:28,110 --> 00:01:30,200 What type should it return? 19 00:01:30,390 --> 00:01:32,140 What will be the name of the function? 20 00:01:32,160 --> 00:01:38,170 OK, most of this information is already there in the instructions of this exercise. 21 00:01:39,060 --> 00:01:46,800 So let us start with the the signature, OK, once you tried it on your own and the signature is going 22 00:01:46,800 --> 00:01:47,730 to look like this. 23 00:01:48,060 --> 00:01:53,460 So first of all, we know that the function may return either zero or one. 24 00:01:53,880 --> 00:02:01,910 So we can assume, OK, in base case because we haven't studied boolean boolean types yet. 25 00:02:01,950 --> 00:02:05,050 So we will assume just the usage of it. 26 00:02:05,080 --> 00:02:08,060 OK, so the function will return an integer. 27 00:02:08,070 --> 00:02:13,910 So either it will be zero or one and then it will specify the function name. 28 00:02:13,920 --> 00:02:18,110 So it will be like is even in the function receives. 29 00:02:18,270 --> 00:02:19,770 What does the function receive. 30 00:02:20,100 --> 00:02:21,990 The function receives an integer. 31 00:02:21,990 --> 00:02:23,810 So let's go into num. 32 00:02:24,030 --> 00:02:32,310 OK, so that's the signature and that's the first step that hopefully you manage to accomplish so far. 33 00:02:33,660 --> 00:02:39,150 And now we have to implement kind of the logic behind this function. 34 00:02:39,930 --> 00:02:42,620 And the logic here is pretty simple. 35 00:02:42,630 --> 00:02:43,950 So it goes like this. 36 00:02:44,370 --> 00:02:46,440 We need to ask a simple question. 37 00:02:46,590 --> 00:02:53,540 If NUM is an even number then return one, otherwise return zero. 38 00:02:54,060 --> 00:02:58,500 So we should basically understand the idea in English. 39 00:02:59,560 --> 00:03:07,180 But whatever language you're using, you're speaking, but here we speak in English, so now basically, 40 00:03:09,160 --> 00:03:13,690 you know what you have to do in practice, but now what you have to do in coding. 41 00:03:13,690 --> 00:03:22,120 So you have to specify the if and then you have to specify the number modulo two, which means that 42 00:03:22,630 --> 00:03:30,010 this will represent the remainder of dividing the value of NUM by two. 43 00:03:30,100 --> 00:03:38,050 If the remainder is zero, then in this case we know that number is an even number, then in this case 44 00:03:38,050 --> 00:03:39,910 we will return one. 45 00:03:40,340 --> 00:03:41,000 All right. 46 00:03:41,800 --> 00:03:49,750 Otherwise, otherwise, ok, we can use or or else we can return to zero. 47 00:03:50,110 --> 00:03:50,670 All right. 48 00:03:50,680 --> 00:03:51,740 Is that clear so far. 49 00:03:53,380 --> 00:03:54,010 Awesome. 50 00:03:54,020 --> 00:03:58,060 So that's basically the implementation for this function. 51 00:03:58,240 --> 00:04:06,280 OK, so this Ale's will be executed only if the result for this condition is false, meaning that if 52 00:04:06,280 --> 00:04:12,500 you divide number by two, you will get a remainder of one, meaning it will be an odd number. 53 00:04:13,180 --> 00:04:14,320 So one question. 54 00:04:14,320 --> 00:04:16,330 Do you think we need this L's here? 55 00:04:16,900 --> 00:04:17,920 I don't think so. 56 00:04:18,100 --> 00:04:20,520 I think we can even leave it like this. 57 00:04:21,130 --> 00:04:23,770 And why will it still be working? 58 00:04:24,460 --> 00:04:32,620 Well, basically, if you return one, then it's kind of an end point for this function and it will 59 00:04:32,620 --> 00:04:35,140 never reach this return zero. 60 00:04:36,070 --> 00:04:45,490 It will only reach this line, these 13 line only if the result of this condition is false, because 61 00:04:45,490 --> 00:04:51,550 if the result of this condition would happen to be true, then in this case this line would have been 62 00:04:51,550 --> 00:04:52,450 executed. 63 00:04:52,870 --> 00:04:56,200 And we know that we can leave it this way. 64 00:04:56,290 --> 00:05:00,450 Of course, if you would have written the else, that's also fine. 65 00:05:00,460 --> 00:05:09,730 I'm just showing you how we can simply like to how we can minimize a few lines of code in this case, 66 00:05:09,730 --> 00:05:11,690 just one line of code. 67 00:05:12,520 --> 00:05:15,340 So, yeah, guys, this is it for this video. 68 00:05:15,340 --> 00:05:22,420 In the next video, I think we should practice and do the same function for is odd and we will use. 69 00:05:23,380 --> 00:05:29,460 Hmm, yeah, basically, let's discuss it in the next video where we are going to solve another function. 70 00:05:29,460 --> 00:05:30,170 I'll see you then. 6620

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