Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
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.