All language subtitles for 7. Function Example 4 - Calc & Return avg between 3 numbers

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,520 --> 00:00:07,360 Welcome back, ladies and gentlemen, to another actually the last example that we are doing in these 2 00:00:07,360 --> 00:00:09,590 functions section together. 3 00:00:09,770 --> 00:00:16,030 And in this example, we are going to write a function that will receive that will receive three numbers, 4 00:00:16,090 --> 00:00:18,820 that we will receive three numbers as a parameters. 5 00:00:19,140 --> 00:00:23,960 And these numbers are and are going to specify the user grades. 6 00:00:24,000 --> 00:00:29,740 So grade one, grade two, grade grade two and grade three. 7 00:00:29,890 --> 00:00:37,030 And once we receive these numbers, the function is going to find out, find out that the average grade 8 00:00:37,360 --> 00:00:39,400 between between them. 9 00:00:40,670 --> 00:00:45,680 OK, and once it's done, the function is going to return in. 10 00:00:45,710 --> 00:00:49,450 The function is going to return these average. 11 00:00:49,540 --> 00:00:50,950 So I hope that's clear. 12 00:00:51,010 --> 00:00:54,550 Let's move on to how we actually implemented. 13 00:00:54,970 --> 00:01:02,110 So we know that the function is going to return as something and this return type is going to be, let's 14 00:01:02,110 --> 00:01:05,020 say, an integer or a floating point. 15 00:01:05,140 --> 00:01:10,550 Actually, I would go with a floating point because we are calculating an average between. 16 00:01:10,660 --> 00:01:17,620 Even if these numbers are off an integer type, we are calculating the average and the average is probably 17 00:01:17,620 --> 00:01:20,260 going to be of a floating point type. 18 00:01:20,380 --> 00:01:23,960 So that's why we are doing float float. 19 00:01:24,310 --> 00:01:30,850 And we specify the name of the function, which is find average. 20 00:01:31,090 --> 00:01:35,510 And now all that would do is to specify the functional receives three raids. 21 00:01:35,650 --> 00:01:41,920 So eighth grade one and grade two and Amed grade three. 22 00:01:42,070 --> 00:01:42,760 That's it. 23 00:01:42,880 --> 00:01:45,490 Now we are going to specify the functions body. 24 00:01:45,490 --> 00:01:48,010 And it's very, very simple. 25 00:01:48,340 --> 00:01:56,310 We are just creating a float type variable to hold the average and we will call it average age or 80 26 00:01:56,360 --> 00:01:57,580 G, whatever you like. 27 00:01:57,670 --> 00:02:01,900 And we can say that Avy G equals to grade one. 28 00:02:02,050 --> 00:02:02,350 Right. 29 00:02:02,380 --> 00:02:08,020 We sum up all the grades rate to plus grade three and all of these. 30 00:02:08,080 --> 00:02:10,590 We divide by three point zero. 31 00:02:10,600 --> 00:02:10,930 Right. 32 00:02:11,020 --> 00:02:14,530 Because we want the result to be of a floating point type. 33 00:02:14,830 --> 00:02:20,230 And this is kind of casting between instead of using just three. 34 00:02:20,260 --> 00:02:21,890 We are using 3.0. 35 00:02:22,030 --> 00:02:25,000 We discussed it in one of our previous lectures. 36 00:02:25,120 --> 00:02:27,820 So the result is going to be a free floating point type. 37 00:02:27,880 --> 00:02:31,510 And we are going to return these average. 38 00:02:31,570 --> 00:02:33,760 So return a V, g. 39 00:02:33,850 --> 00:02:34,780 And that's it. 40 00:02:35,140 --> 00:02:39,130 That's basically the whole thing that these function does. 41 00:02:39,470 --> 00:02:39,850 All right. 42 00:02:39,880 --> 00:02:40,900 Nothing complicated. 43 00:02:41,020 --> 00:02:43,030 Receives three numbers. 44 00:02:43,060 --> 00:02:44,950 It knows to receive three numbers. 45 00:02:45,220 --> 00:02:47,860 And just to find out the average between them. 46 00:02:47,980 --> 00:02:54,040 Now let's see how we can use the main function to to read from the user, for example, the GREs, and 47 00:02:54,040 --> 00:02:55,910 then to call these function. 48 00:02:55,990 --> 00:03:01,670 So we'll create, let's say, into G1, G2 and G3. 49 00:03:02,200 --> 00:03:07,210 And then we are going to print out enter three grades. 50 00:03:07,570 --> 00:03:08,080 Okay. 51 00:03:08,560 --> 00:03:21,820 And we are going to read these three grades inside of these variables, Internet G1, G two and G three. 52 00:03:22,310 --> 00:03:23,070 G three. 53 00:03:24,430 --> 00:03:24,640 Okay. 54 00:03:24,700 --> 00:03:25,630 Is that clear? 55 00:03:25,720 --> 00:03:31,950 And now what we want to do is we know that we have a function that finds the average. 56 00:03:31,960 --> 00:03:35,590 We don't need to find and calculate the average here. 57 00:03:35,590 --> 00:03:41,470 We can use some guy, some specialist that we've created to find the average. 58 00:03:41,680 --> 00:03:44,260 He is responsible of all of these operations. 59 00:03:44,290 --> 00:03:49,270 So we can say that let's use it in just one line. 60 00:03:49,570 --> 00:03:59,200 We will print the result after wars and will print out that the average equals to percentage F and instead 61 00:03:59,200 --> 00:04:00,700 of these percentage F, right. 62 00:04:00,730 --> 00:04:03,850 We expect to specify here a value. 63 00:04:04,360 --> 00:04:06,850 So what value should we write here? 64 00:04:07,420 --> 00:04:12,010 We can actually write the function name, which is find average. 65 00:04:12,730 --> 00:04:14,210 And all of these. 66 00:04:14,230 --> 00:04:18,940 G one due to G three to proceed as an argument. 67 00:04:19,120 --> 00:04:21,220 Each argument to a parameter. 68 00:04:21,340 --> 00:04:27,850 And instead of these functions that we specified, instead of this expression, we are going to execute. 69 00:04:28,120 --> 00:04:30,280 These are lines of code. 70 00:04:30,340 --> 00:04:31,870 So one, two, three. 71 00:04:32,200 --> 00:04:39,520 And once we return the average instead of these expression here, we will have the average value, which 72 00:04:39,520 --> 00:04:41,710 is a way over a floating point type. 73 00:04:42,190 --> 00:04:45,250 And instead of this place holder percentage F. 74 00:04:45,610 --> 00:04:49,660 We are going to see the result of the average. 75 00:04:49,750 --> 00:04:51,970 So that's very important to understand. 76 00:04:52,150 --> 00:04:56,740 Instead of these guy, there is going to be the average return from the function. 77 00:04:57,250 --> 00:04:59,250 And instead of this percentage F.. 78 00:04:59,320 --> 00:04:59,830 This is the. 79 00:05:00,190 --> 00:05:03,490 Value that is going to be replaced in this place holder. 80 00:05:03,580 --> 00:05:06,430 So let's try to build and run it and see what happens. 81 00:05:06,490 --> 00:05:12,430 So let's go with something like this, 80, 90 and a hundred. 82 00:05:13,180 --> 00:05:15,280 So the average is 90 is expected. 83 00:05:15,550 --> 00:05:17,050 Let's do something like this. 84 00:05:17,080 --> 00:05:18,800 Let's go with 90. 85 00:05:19,180 --> 00:05:21,760 Eighty five and eighty two. 86 00:05:22,420 --> 00:05:26,590 So the average you can see it's off a floating point type, which is great. 87 00:05:27,010 --> 00:05:30,730 And it seems to be working as expected. 88 00:05:31,180 --> 00:05:33,100 So this is it for this video. 89 00:05:33,250 --> 00:05:37,240 I hope you enjoyed this tutorial this week. 90 00:05:37,600 --> 00:05:40,900 Demonstration of a couple of examples that we've done right now. 91 00:05:41,230 --> 00:05:47,920 And you are ready to move on to the next exercises and the next challenges and the next milestones in 92 00:05:47,920 --> 00:05:50,900 these amazing C programming chorus. 93 00:05:51,610 --> 00:05:52,810 Thank you guys for watching. 94 00:05:52,840 --> 00:05:54,190 I'll see you in the next video. 8109

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