All language subtitles for 5. Function Example 2 - Print Max between 2 Integers

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,480 --> 00:00:06,300 Welcome back, ladies and gentlemen, and this is another exercise where we are going to practice our 2 00:00:06,810 --> 00:00:10,110 function skills in C programming language. 3 00:00:10,260 --> 00:00:16,980 And in this exercise, what we are going to do is we are going to write a function that receives receives 4 00:00:16,980 --> 00:00:17,910 two numbers. 5 00:00:17,970 --> 00:00:19,380 It receives two numbers. 6 00:00:19,500 --> 00:00:26,010 And then all it does is simply to print out, to print out which one of them is the maximum print out, 7 00:00:26,310 --> 00:00:31,170 which one of them is the maximum so maximal and which one of them is the minimum. 8 00:00:31,380 --> 00:00:37,380 So, for example, if we will have if we will have, let's say nine one equals two five and two equals 9 00:00:37,380 --> 00:00:38,220 two seven. 10 00:00:38,700 --> 00:00:45,510 So in this case, with the function is going to print maximum equals to seven. 11 00:00:45,540 --> 00:00:45,960 Right. 12 00:00:46,020 --> 00:00:49,320 And minimal meaning more equals two. 13 00:00:49,350 --> 00:00:49,830 Five. 14 00:00:49,950 --> 00:00:50,580 That's it. 15 00:00:50,670 --> 00:00:56,850 So if we come to think about this function, about what will be Stipe, we can see that this function 16 00:00:56,880 --> 00:01:03,570 does not return anything, although these function prints something to the screen, prints the maximum 17 00:01:03,570 --> 00:01:04,500 preens at the minimum. 18 00:01:05,250 --> 00:01:10,530 It doesn't matter because we do not see anything that related to the return statement. 19 00:01:10,650 --> 00:01:13,530 The function will be the arm of type void. 20 00:01:13,560 --> 00:01:13,920 Right. 21 00:01:14,010 --> 00:01:17,910 And then we are going also to specify the function name. 22 00:01:18,210 --> 00:01:22,250 So for this example, it's a print mean marks. 23 00:01:22,530 --> 00:01:26,610 Please remember that it's very important to give your function name. 24 00:01:27,420 --> 00:01:32,970 Something useful, something meaningful that will describe the content, the meaning of the function 25 00:01:32,970 --> 00:01:34,080 when the function does. 26 00:01:34,200 --> 00:01:39,600 And right after work, we are going to specify the parameters that the functional will receive. 27 00:01:39,620 --> 00:01:43,320 So we can see here that the functional receives two numbers. 28 00:01:43,380 --> 00:01:46,960 So two numbers, let's say, of an integer, a type. 29 00:01:47,100 --> 00:01:51,870 So we can use something like this into one and into number two. 30 00:01:52,320 --> 00:01:57,330 And at this point, we know that the function received everything that is needed. 31 00:01:57,480 --> 00:02:02,130 And now we are going to write the functions body in these curly brackets. 32 00:02:02,250 --> 00:02:04,530 So the function actually is pretty simple. 33 00:02:04,890 --> 00:02:07,020 First of all, you just ease a condition. 34 00:02:07,030 --> 00:02:08,730 So you just go something like this. 35 00:02:09,060 --> 00:02:14,990 If no one is greater than NUM two, then in this case you are going to do the following. 36 00:02:15,000 --> 00:02:18,630 You are going to print to the screen that the maximum. 37 00:02:18,900 --> 00:02:20,310 Between these two number. 38 00:02:20,700 --> 00:02:25,570 Between these two numbers is the percentage D backslash shann. 39 00:02:25,860 --> 00:02:28,530 And in this case, it will be simply No. 40 00:02:28,530 --> 00:02:29,150 One, right. 41 00:02:29,190 --> 00:02:33,620 Because it's greater than NUM two, meaning it's the maximum, obviously. 42 00:02:33,930 --> 00:02:36,240 So this will be number one. 43 00:02:36,570 --> 00:02:40,130 And similarly, we are going to do it for the minimum between these two. 44 00:02:40,170 --> 00:02:42,370 We know that if if that's the maximum. 45 00:02:42,390 --> 00:02:46,980 Then of course, this one will be less than num one. 46 00:02:47,070 --> 00:02:48,750 So we are going to write down. 47 00:02:49,230 --> 00:02:54,900 Minimum is percentage and just change it from num one to num two. 48 00:02:55,050 --> 00:02:55,610 All right. 49 00:02:55,620 --> 00:02:56,070 Very good. 50 00:02:56,100 --> 00:03:04,350 Now, what we have to do is simply to specify the else statement, meaning if no one is not greater 51 00:03:04,410 --> 00:03:05,110 than two. 52 00:03:05,490 --> 00:03:11,670 Then what we are going to do is we are going to execute these block of code. 53 00:03:11,730 --> 00:03:16,530 So in this case, the print F commands are going to be very, very similar. 54 00:03:16,530 --> 00:03:19,600 Where will we were just going to copy them? 55 00:03:19,620 --> 00:03:23,840 So we are going to do something like this, bring def maximum is it. 56 00:03:23,970 --> 00:03:24,540 And accept. 57 00:03:24,640 --> 00:03:30,240 And instead of this percentage which is used for nowon, we are going to use them too. 58 00:03:30,600 --> 00:03:36,870 And here we are going to use now one for the minimum rate because this else section is only executed 59 00:03:37,110 --> 00:03:43,110 if num two is at least Rayder or equals two now one. 60 00:03:43,620 --> 00:03:47,370 So in this case we will assume that NUM one is the maximum. 61 00:03:47,580 --> 00:03:47,910 Right. 62 00:03:47,940 --> 00:03:51,920 It's at least equals to num one or greater than one. 63 00:03:52,160 --> 00:03:53,590 Here are the minimum we use num one. 64 00:03:53,610 --> 00:03:55,080 So simple is that. 65 00:03:55,160 --> 00:04:00,510 And one thing I want you to notice is that this function, this function Brint mean marks. 66 00:04:00,930 --> 00:04:03,350 This function does not return anything. 67 00:04:03,420 --> 00:04:06,500 You can see that there is no line like this return. 68 00:04:06,620 --> 00:04:06,790 No. 69 00:04:07,050 --> 00:04:07,620 Minimal. 70 00:04:07,650 --> 00:04:10,110 More turned maximum or something like that. 71 00:04:10,380 --> 00:04:12,460 We do not return anything. 72 00:04:12,480 --> 00:04:18,540 And the reason is because these function, these functions of type void and it shouldn't return anything, 73 00:04:18,540 --> 00:04:20,970 just should print something to the screen. 74 00:04:21,300 --> 00:04:26,940 So, you know, the difference between printing and returning something to the calling function. 75 00:04:26,970 --> 00:04:27,300 Right. 76 00:04:27,390 --> 00:04:28,310 And there you go. 77 00:04:28,320 --> 00:04:29,720 Whiskery can say that. 78 00:04:29,760 --> 00:04:31,350 Let's remove these two lines. 79 00:04:31,380 --> 00:04:35,190 We can say that the print mean marks function is over. 80 00:04:35,190 --> 00:04:36,660 We we are done with it. 81 00:04:36,990 --> 00:04:43,560 Now, what interest us sees to write are the main function in to see how we call this printing marks. 82 00:04:43,830 --> 00:04:45,630 So that's actually very simple. 83 00:04:45,900 --> 00:04:54,540 Let's just use int A and B, we create two variables, A and B, which are a local to these main function. 84 00:04:54,540 --> 00:04:54,840 Right. 85 00:04:54,870 --> 00:04:59,880 We can not access them, at least at least at this point we cannot access them. 86 00:05:00,240 --> 00:05:04,890 Through these functions, so these a ANP are local to the main function. 87 00:05:05,170 --> 00:05:07,530 And now we are going to write a print. 88 00:05:08,790 --> 00:05:11,700 Please enter number one and number two. 89 00:05:11,850 --> 00:05:16,560 So print f Panter num number one. 90 00:05:16,980 --> 00:05:17,290 Right. 91 00:05:17,760 --> 00:05:20,540 This will go for R for the A.. 92 00:05:20,610 --> 00:05:27,450 So now we are going to use the scanner percentage, the story inside the first variable. 93 00:05:27,810 --> 00:05:31,920 And similarly, we are going to do the same for the second variable. 94 00:05:32,040 --> 00:05:37,140 So just use print F and enter number two. 95 00:05:37,660 --> 00:05:43,290 And now you are going to use the scanner F to really attan percentage B. 96 00:05:44,110 --> 00:05:45,020 And that's set. 97 00:05:45,390 --> 00:05:50,040 Now, what you are going to do is simply simply call this function, right. 98 00:05:50,310 --> 00:05:57,070 We have already two numbers, two variables, and we want to find out which one of them is the maximum. 99 00:05:57,090 --> 00:05:58,590 In which one of them is the minimum. 100 00:05:58,680 --> 00:06:04,380 So in this case, we will simply call the function we know that we can call X function just by specifying 101 00:06:04,380 --> 00:06:04,800 its name. 102 00:06:04,810 --> 00:06:06,010 So print mean marks. 103 00:06:06,120 --> 00:06:06,490 All right. 104 00:06:06,840 --> 00:06:07,860 So there you go. 105 00:06:07,860 --> 00:06:10,680 Print mean marks, print mean marks. 106 00:06:10,950 --> 00:06:17,010 And in the parentheses, we are going to specify what these function will receive as a parameter. 107 00:06:17,070 --> 00:06:18,970 So that's the first parameter in. 108 00:06:19,050 --> 00:06:24,790 Number one in NUM one, we are going to send the value of a and for now two. 109 00:06:25,020 --> 00:06:26,070 Here you can see it. 110 00:06:26,340 --> 00:06:31,860 We are going to send the value of B and at the end of course, specified the semicolon. 111 00:06:32,050 --> 00:06:35,700 And now let's try to build and run it and see what happens. 112 00:06:35,970 --> 00:06:38,430 So here we go, enter nine one. 113 00:06:38,670 --> 00:06:42,390 So as we've using our example, five and seven. 114 00:06:42,900 --> 00:06:44,140 So there you go. 115 00:06:44,160 --> 00:06:45,120 There you can see it. 116 00:06:45,150 --> 00:06:47,820 Maximum is seven and minimum is five. 117 00:06:48,120 --> 00:06:49,630 And we can try another example. 118 00:06:49,650 --> 00:06:50,400 Let's run it. 119 00:06:50,790 --> 00:06:51,980 Let's do something like this. 120 00:06:51,990 --> 00:06:54,070 A hundred and 5000. 121 00:06:54,870 --> 00:06:57,490 So 5000 is obviously the maximum. 122 00:06:57,540 --> 00:06:59,790 This case in one hundred is the minimum. 123 00:07:00,120 --> 00:07:01,920 So I hope this example is clear. 124 00:07:02,520 --> 00:07:09,930 Basically, what we've done here is we've written a function of type of off a void type, receiving 125 00:07:09,960 --> 00:07:13,270 two parameters and running some commands. 126 00:07:13,320 --> 00:07:20,940 Some conditions and some printing to the screen commands with messages of maximum and minimum. 127 00:07:21,660 --> 00:07:23,450 So there's need for this video, guys. 128 00:07:23,610 --> 00:07:25,230 I hope you enjoyed it. 129 00:07:25,560 --> 00:07:27,750 And we are going to proceed with the third one. 130 00:07:28,200 --> 00:07:28,910 I'll see you there. 11356

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