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
All right, so what we are going to do now is, first of all, we are going to remove all of these lines
of code along the main section and we are going to start from scratch.
And in this exercise, we are going to write a function that simply receives nothing.
It receives no no parameters.
All right.
Receives nothing.
But.
But the function will, first of all, return something.
All right.
So the function will return some value previously in the first two exercise, if I'm not mistaken.
We did not return anything.
We just used to function Sophi void type.
But that's about to change right now.
So the function will return something.
But one, a functional will do the functional.
We'll get the function by itself.
We'll get from the user three numbers as input.
Right.
It will ask the user to insert the three numbers similarly to how we do it in the main function.
But now we are going to do it inside of different function, inside of another function, which is also
OK.
Right.
There is nothing wrong about it.
And the function will these function will find the maximum value, the maximum.
Between these three given numbers.
OK, numbers.
And then of course, the function is going return the maximum that we just found.
So how should we approach these function?
How should we approach?
And how should we solve this exercise?
So first of all, we know that the function is going to return something and that's a maximum value.
And we know that the C will be the maximum between given three numbers.
And we will assume that these three numbers, just for convenience C are going to be of an integer type.
Right.
So they are going to be an integer, a type.
And that's why we can say that the type of the function is also going to be in.
So we are specifying ENT as the type of the function.
Now what we are going to do is specify the function name and we will go with something like this marks
between three.
Let's call it like this.
And the functional receives nothing.
So these are parentheses are going to be empty.
And now all that remains is simply to specify the function body.
You see, guys, these are these case when you do not get any parameter is also OK.
There is no necessity to always give here.
And there is now more char, a son, some character and so on.
It also can remain empty.
So now it's type of a function.
Let's write down the function body.
So what we should do here?
How should we find the maximum between three numbers?
We, we we should use some condition.
Definite conditions, definitely.
But we are going to start from here.
We are going to get from the user three numbers as input.
So for that, we are going, first of all, to create these numbers.
So income one, number two and number three.
And now we are going to use some guiding math sense.
So answer No.
One.
Number two and three.
Okay.
So that's it.
And now we are going to read from the console are the values that the user specifies.
And we are going to do it.
I'm going to show you something new.
We are going to do it with just one scan F function.
We are going to specify percentage, the percentage, the center Jdey and percent the Judy.
And we are going to specify where we are going to store every value that we use by these place holders.
So the first value is going to go to number one, the second to none, too.
And this third one.
Now three.
All right.
So that's basically pretty much the same as you would have used three.
Scan F commands in three lines.
We can do all of these in just one line.
Now, what we should do is simply to use some conditions.
So, first of all, let's think about how we should solve it.
We should aim to find the maximum between three numbers.
And we've seen, if I'm not mistaken, some example like this where we had to write these inside of
these AMED main function.
It's just that right now we are going to write it inside of other function that we've called it, Max,
between three.
So the first thing we are going to do is to specify if no one is greater than NUM two, which means
there is a chance.
If that's the case, if that happens to be true, there is a chance that no one will be the maximum.
And all that.
Means in such cases to check if no one is also greater.
There are now three.
That's the case.
We know that number one will be the maximum rate because it's greater than two and greater than three.
So in this case, we are going to return right.
To return number one.
So if this line will be executed, we are going to step out of this function without even care what
will happen afterwards.
But if that's not the case, if we have here are the L's section, we are going to specify what what
do you think?
We are going to specify a return.
Now, three, is that correct?
So, yes, that's definitely correct.
And the reason for that is because if number two is greater than if number one is greater than I'm M2,
but number one is less than the number three, then definitely number three is greater than one.
But no one is greater than number two.
So that's why we are going to return number three.
But if that condition for this, if the result for this condition was false, then we are going to use
here.
And else if we are going to specify if number two is greater than number three, then in this case we
are going to return to.
And also the L section, if this condition happens to also to be false.
We are going to turn now three.
Is that clear?
The logic and everything behind these functionality of finding the maximum between three values is something
that you have to understand to some extent, at least at this point.
And what interests us here is not the logic behind it is actually how we formulate and how we use function
that returns something an int value and receives nothing and reads from the user some numbers.
So that's okay.
And now let's go to see how we can call these function inside of the main function, and we can say
that it will pretty much be very easy list.
First of all, create a max variable because we know that these function, these max between three will
return something.
It will return something of type int.
So we want to catch to get what in to get in store, what these functions will return inside of some
variable.
And in this case this variable is going to be Max.
So we can say that Mock's equals.
Right.
We use the assignment operator because these function returns something and instead of the function
that we use here makes between three.
Right.
We we will receive once it's over, once these function is complete, here will be instead of these
expression, here will be the result that the functional return, whether we will be num one, num two
or number three value.
So now let's see how these function looks like found.
We'll then run it.
So enter now one, number two.
And number three, let's say that no one will be five.
And number two will be seven.
And number.
We will be nine.
Now we will press enter.
And basically nothing happened.
So why is that?
That's because of a function itself.
Did not print anything to the screen, to the console application.
The function just return some value between these two function.
Right.
These two functions.
They talked to each other.
This one they amed main called these marks between three and these marks between three.
Return some value to mean.
It didn't print anything to the screen.
But if we did want to print the maximum result of the screen, we should do something like this.
We should do print F maximum equals two percentage D, and instead of this percentage, we are going
to specify what resides in these max variable, which is basically the resolved return from max between
three function.
So we will just do something like this, Max, and semicolon at the end.
And let's try to build in running once again.
And we can see that.
Let's see.
We can see that five, seven and nine.
These were our previous examples.
So five, seven and nine.
And the maximum equals two nine, which is exactly what we expected.
Let's try to ride once again with some different values.
So five, fifteen and ten.
So the maximum is fifteen.
And it seems that the function is working as expected.
So this is a four of these video guys say, hope you enjoyed it and I'll see in the next one.
We are we are going to talk about another example of function user, just where we are going to return
some value.
And the function also is going to receive sound parameters.
Which something that didn't happen in this example.
So until next time, I'll see you there.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.