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
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

Original subtitles

Welcome back, ladies and gentlemen, to another actually the last example that we are doing in these

functions section together.

And in this example, we are going to write a function that will receive that will receive three numbers,

that we will receive three numbers as a parameters.

And these numbers are and are going to specify the user grades.

So grade one, grade two, grade grade two and grade three.

And once we receive these numbers, the function is going to find out, find out that the average grade

between between them.

OK, and once it's done, the function is going to return in.

The function is going to return these average.

So I hope that's clear.

Let's move on to how we actually implemented.

So we know that the function is going to return as something and this return type is going to be, let's

say, an integer or a floating point.

Actually, I would go with a floating point because we are calculating an average between.

Even if these numbers are off an integer type, we are calculating the average and the average is probably

going to be of a floating point type.

So that's why we are doing float float.

And we specify the name of the function, which is find average.

And now all that would do is to specify the functional receives three raids.

So eighth grade one and grade two and Amed grade three.

That's it.

Now we are going to specify the functions body.

And it's very, very simple.

We are just creating a float type variable to hold the average and we will call it average age or 80

G, whatever you like.

And we can say that Avy G equals to grade one.

Right.

We sum up all the grades rate to plus grade three and all of these.

We divide by three point zero.

Right.

Because we want the result to be of a floating point type.

And this is kind of casting between instead of using just three.

We are using 3.0.

We discussed it in one of our previous lectures.

So the result is going to be a free floating point type.

And we are going to return these average.

So return a V, g.

And that's it.

That's basically the whole thing that these function does.

All right.

Nothing complicated.

Receives three numbers.

It knows to receive three numbers.

And just to find out the average between them.

Now let's see how we can use the main function to to read from the user, for example, the GREs, and

then to call these function.

So we'll create, let's say, into G1, G2 and G3.

And then we are going to print out enter three grades.

Okay.

And we are going to read these three grades inside of these variables, Internet G1, G two and G three.

G three.

Okay.

Is that clear?

And now what we want to do is we know that we have a function that finds the average.

We don't need to find and calculate the average here.

We can use some guy, some specialist that we've created to find the average.

He is responsible of all of these operations.

So we can say that let's use it in just one line.

We will print the result after wars and will print out that the average equals to percentage F and instead

of these percentage F, right.

We expect to specify here a value.

So what value should we write here?

We can actually write the function name, which is find average.

And all of these.

G one due to G three to proceed as an argument.

Each argument to a parameter.

And instead of these functions that we specified, instead of this expression, we are going to execute.

These are lines of code.

So one, two, three.

And once we return the average instead of these expression here, we will have the average value, which

is a way over a floating point type.

And instead of this place holder percentage F.

We are going to see the result of the average.

So that's very important to understand.

Instead of these guy, there is going to be the average return from the function.

And instead of this percentage F..

This is the.

Value that is going to be replaced in this place holder.

So let's try to build and run it and see what happens.

So let's go with something like this, 80, 90 and a hundred.

So the average is 90 is expected.

Let's do something like this.

Let's go with 90.

Eighty five and eighty two.

So the average you can see it's off a floating point type, which is great.

And it seems to be working as expected.

So this is it for this video.

I hope you enjoyed this tutorial this week.

Demonstration of a couple of examples that we've done right now.

And you are ready to move on to the next exercises and the next challenges and the next milestones in

these amazing C programming chorus.

Thank you guys for watching.

I'll see you in the next video.

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