Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,510 --> 00:00:06,600
All right, so what we are going to do now is, first of all, we are going to remove all of these lines
2
00:00:06,600 --> 00:00:11,220
of code along the main section and we are going to start from scratch.
3
00:00:11,330 --> 00:00:16,590
And in this exercise, we are going to write a function that simply receives nothing.
4
00:00:16,860 --> 00:00:21,060
It receives no no parameters.
5
00:00:21,290 --> 00:00:21,720
All right.
6
00:00:21,930 --> 00:00:23,040
Receives nothing.
7
00:00:23,140 --> 00:00:23,650
But.
8
00:00:24,030 --> 00:00:27,360
But the function will, first of all, return something.
9
00:00:27,720 --> 00:00:28,050
All right.
10
00:00:28,080 --> 00:00:34,380
So the function will return some value previously in the first two exercise, if I'm not mistaken.
11
00:00:34,680 --> 00:00:37,070
We did not return anything.
12
00:00:37,080 --> 00:00:40,680
We just used to function Sophi void type.
13
00:00:40,740 --> 00:00:43,410
But that's about to change right now.
14
00:00:43,470 --> 00:00:45,570
So the function will return something.
15
00:00:45,570 --> 00:00:47,860
But one, a functional will do the functional.
16
00:00:47,880 --> 00:00:50,340
We'll get the function by itself.
17
00:00:50,370 --> 00:00:56,520
We'll get from the user three numbers as input.
18
00:00:56,790 --> 00:00:57,100
Right.
19
00:00:57,240 --> 00:01:03,960
It will ask the user to insert the three numbers similarly to how we do it in the main function.
20
00:01:04,440 --> 00:01:10,700
But now we are going to do it inside of different function, inside of another function, which is also
21
00:01:10,710 --> 00:01:10,970
OK.
22
00:01:11,040 --> 00:01:11,340
Right.
23
00:01:11,430 --> 00:01:12,900
There is nothing wrong about it.
24
00:01:13,440 --> 00:01:18,900
And the function will these function will find the maximum value, the maximum.
25
00:01:18,920 --> 00:01:23,320
Between these three given numbers.
26
00:01:23,910 --> 00:01:25,200
OK, numbers.
27
00:01:25,410 --> 00:01:29,970
And then of course, the function is going return the maximum that we just found.
28
00:01:30,060 --> 00:01:32,400
So how should we approach these function?
29
00:01:32,430 --> 00:01:33,570
How should we approach?
30
00:01:33,930 --> 00:01:36,030
And how should we solve this exercise?
31
00:01:36,300 --> 00:01:43,010
So first of all, we know that the function is going to return something and that's a maximum value.
32
00:01:43,020 --> 00:01:47,960
And we know that the C will be the maximum between given three numbers.
33
00:01:47,970 --> 00:01:55,500
And we will assume that these three numbers, just for convenience C are going to be of an integer type.
34
00:01:55,660 --> 00:01:55,950
Right.
35
00:01:55,950 --> 00:01:58,110
So they are going to be an integer, a type.
36
00:01:58,320 --> 00:02:02,910
And that's why we can say that the type of the function is also going to be in.
37
00:02:02,970 --> 00:02:07,200
So we are specifying ENT as the type of the function.
38
00:02:07,320 --> 00:02:13,140
Now what we are going to do is specify the function name and we will go with something like this marks
39
00:02:13,530 --> 00:02:14,820
between three.
40
00:02:15,000 --> 00:02:16,560
Let's call it like this.
41
00:02:16,920 --> 00:02:18,810
And the functional receives nothing.
42
00:02:19,140 --> 00:02:23,490
So these are parentheses are going to be empty.
43
00:02:23,800 --> 00:02:27,470
And now all that remains is simply to specify the function body.
44
00:02:28,010 --> 00:02:33,950
You see, guys, these are these case when you do not get any parameter is also OK.
45
00:02:34,290 --> 00:02:38,430
There is no necessity to always give here.
46
00:02:38,430 --> 00:02:43,080
And there is now more char, a son, some character and so on.
47
00:02:43,590 --> 00:02:45,630
It also can remain empty.
48
00:02:45,690 --> 00:02:48,210
So now it's type of a function.
49
00:02:48,330 --> 00:02:49,980
Let's write down the function body.
50
00:02:50,220 --> 00:02:52,260
So what we should do here?
51
00:02:52,320 --> 00:02:56,220
How should we find the maximum between three numbers?
52
00:02:56,600 --> 00:02:58,650
We, we we should use some condition.
53
00:02:58,680 --> 00:03:00,150
Definite conditions, definitely.
54
00:03:00,150 --> 00:03:03,180
But we are going to start from here.
55
00:03:03,180 --> 00:03:07,140
We are going to get from the user three numbers as input.
56
00:03:07,530 --> 00:03:11,170
So for that, we are going, first of all, to create these numbers.
57
00:03:11,220 --> 00:03:14,490
So income one, number two and number three.
58
00:03:14,910 --> 00:03:18,670
And now we are going to use some guiding math sense.
59
00:03:18,750 --> 00:03:20,730
So answer No.
60
00:03:20,970 --> 00:03:21,600
One.
61
00:03:22,110 --> 00:03:25,110
Number two and three.
62
00:03:25,560 --> 00:03:25,880
Okay.
63
00:03:27,360 --> 00:03:28,200
So that's it.
64
00:03:28,740 --> 00:03:34,800
And now we are going to read from the console are the values that the user specifies.
65
00:03:35,100 --> 00:03:36,530
And we are going to do it.
66
00:03:36,600 --> 00:03:38,130
I'm going to show you something new.
67
00:03:38,250 --> 00:03:42,210
We are going to do it with just one scan F function.
68
00:03:42,510 --> 00:03:47,900
We are going to specify percentage, the percentage, the center Jdey and percent the Judy.
69
00:03:48,660 --> 00:03:56,970
And we are going to specify where we are going to store every value that we use by these place holders.
70
00:03:57,030 --> 00:04:01,780
So the first value is going to go to number one, the second to none, too.
71
00:04:02,010 --> 00:04:03,660
And this third one.
72
00:04:03,930 --> 00:04:04,590
Now three.
73
00:04:04,830 --> 00:04:05,250
All right.
74
00:04:05,250 --> 00:04:10,720
So that's basically pretty much the same as you would have used three.
75
00:04:11,060 --> 00:04:13,920
Scan F commands in three lines.
76
00:04:13,950 --> 00:04:16,440
We can do all of these in just one line.
77
00:04:16,750 --> 00:04:20,130
Now, what we should do is simply to use some conditions.
78
00:04:20,190 --> 00:04:24,030
So, first of all, let's think about how we should solve it.
79
00:04:24,060 --> 00:04:28,560
We should aim to find the maximum between three numbers.
80
00:04:28,920 --> 00:04:36,360
And we've seen, if I'm not mistaken, some example like this where we had to write these inside of
81
00:04:36,360 --> 00:04:37,980
these AMED main function.
82
00:04:38,100 --> 00:04:43,830
It's just that right now we are going to write it inside of other function that we've called it, Max,
83
00:04:43,840 --> 00:04:44,670
between three.
84
00:04:44,790 --> 00:04:51,990
So the first thing we are going to do is to specify if no one is greater than NUM two, which means
85
00:04:52,060 --> 00:04:52,990
there is a chance.
86
00:04:53,010 --> 00:04:58,680
If that's the case, if that happens to be true, there is a chance that no one will be the maximum.
87
00:04:59,040 --> 00:04:59,670
And all that.
88
00:04:59,900 --> 00:05:04,520
Means in such cases to check if no one is also greater.
89
00:05:04,550 --> 00:05:05,630
There are now three.
90
00:05:06,380 --> 00:05:07,130
That's the case.
91
00:05:07,130 --> 00:05:13,250
We know that number one will be the maximum rate because it's greater than two and greater than three.
92
00:05:13,730 --> 00:05:17,120
So in this case, we are going to return right.
93
00:05:17,300 --> 00:05:19,290
To return number one.
94
00:05:19,610 --> 00:05:28,040
So if this line will be executed, we are going to step out of this function without even care what
95
00:05:28,040 --> 00:05:29,480
will happen afterwards.
96
00:05:29,870 --> 00:05:37,460
But if that's not the case, if we have here are the L's section, we are going to specify what what
97
00:05:37,460 --> 00:05:37,940
do you think?
98
00:05:37,970 --> 00:05:39,830
We are going to specify a return.
99
00:05:40,030 --> 00:05:41,810
Now, three, is that correct?
100
00:05:42,260 --> 00:05:44,600
So, yes, that's definitely correct.
101
00:05:45,020 --> 00:05:51,680
And the reason for that is because if number two is greater than if number one is greater than I'm M2,
102
00:05:51,950 --> 00:05:58,120
but number one is less than the number three, then definitely number three is greater than one.
103
00:05:58,310 --> 00:06:00,260
But no one is greater than number two.
104
00:06:00,590 --> 00:06:03,140
So that's why we are going to return number three.
105
00:06:03,800 --> 00:06:09,650
But if that condition for this, if the result for this condition was false, then we are going to use
106
00:06:09,650 --> 00:06:09,980
here.
107
00:06:09,980 --> 00:06:17,450
And else if we are going to specify if number two is greater than number three, then in this case we
108
00:06:17,450 --> 00:06:19,040
are going to return to.
109
00:06:19,460 --> 00:06:24,950
And also the L section, if this condition happens to also to be false.
110
00:06:25,280 --> 00:06:28,310
We are going to turn now three.
111
00:06:29,060 --> 00:06:29,900
Is that clear?
112
00:06:29,990 --> 00:06:36,260
The logic and everything behind these functionality of finding the maximum between three values is something
113
00:06:36,260 --> 00:06:41,510
that you have to understand to some extent, at least at this point.
114
00:06:41,960 --> 00:06:49,730
And what interests us here is not the logic behind it is actually how we formulate and how we use function
115
00:06:50,060 --> 00:06:58,870
that returns something an int value and receives nothing and reads from the user some numbers.
116
00:06:59,000 --> 00:07:00,130
So that's okay.
117
00:07:00,140 --> 00:07:06,620
And now let's go to see how we can call these function inside of the main function, and we can say
118
00:07:06,620 --> 00:07:09,740
that it will pretty much be very easy list.
119
00:07:09,830 --> 00:07:15,920
First of all, create a max variable because we know that these function, these max between three will
120
00:07:16,070 --> 00:07:17,420
return something.
121
00:07:17,420 --> 00:07:19,600
It will return something of type int.
122
00:07:20,120 --> 00:07:27,110
So we want to catch to get what in to get in store, what these functions will return inside of some
123
00:07:27,110 --> 00:07:27,770
variable.
124
00:07:27,770 --> 00:07:31,160
And in this case this variable is going to be Max.
125
00:07:31,250 --> 00:07:33,500
So we can say that Mock's equals.
126
00:07:33,530 --> 00:07:33,800
Right.
127
00:07:33,830 --> 00:07:40,760
We use the assignment operator because these function returns something and instead of the function
128
00:07:40,760 --> 00:07:42,740
that we use here makes between three.
129
00:07:43,180 --> 00:07:43,530
Right.
130
00:07:43,970 --> 00:07:50,810
We we will receive once it's over, once these function is complete, here will be instead of these
131
00:07:51,380 --> 00:07:57,770
expression, here will be the result that the functional return, whether we will be num one, num two
132
00:07:57,770 --> 00:07:58,970
or number three value.
133
00:07:59,030 --> 00:08:02,570
So now let's see how these function looks like found.
134
00:08:02,690 --> 00:08:03,740
We'll then run it.
135
00:08:04,310 --> 00:08:06,320
So enter now one, number two.
136
00:08:06,320 --> 00:08:09,590
And number three, let's say that no one will be five.
137
00:08:10,130 --> 00:08:11,840
And number two will be seven.
138
00:08:11,870 --> 00:08:12,290
And number.
139
00:08:12,350 --> 00:08:13,400
We will be nine.
140
00:08:13,640 --> 00:08:15,110
Now we will press enter.
141
00:08:15,500 --> 00:08:17,780
And basically nothing happened.
142
00:08:18,080 --> 00:08:19,250
So why is that?
143
00:08:19,370 --> 00:08:21,740
That's because of a function itself.
144
00:08:21,860 --> 00:08:25,580
Did not print anything to the screen, to the console application.
145
00:08:25,610 --> 00:08:30,560
The function just return some value between these two function.
146
00:08:30,590 --> 00:08:30,860
Right.
147
00:08:31,670 --> 00:08:32,600
These two functions.
148
00:08:32,630 --> 00:08:34,130
They talked to each other.
149
00:08:34,220 --> 00:08:39,710
This one they amed main called these marks between three and these marks between three.
150
00:08:39,770 --> 00:08:42,370
Return some value to mean.
151
00:08:42,440 --> 00:08:44,480
It didn't print anything to the screen.
152
00:08:45,020 --> 00:08:50,580
But if we did want to print the maximum result of the screen, we should do something like this.
153
00:08:50,600 --> 00:08:58,070
We should do print F maximum equals two percentage D, and instead of this percentage, we are going
154
00:08:58,070 --> 00:09:06,380
to specify what resides in these max variable, which is basically the resolved return from max between
155
00:09:06,380 --> 00:09:07,220
three function.
156
00:09:07,460 --> 00:09:11,570
So we will just do something like this, Max, and semicolon at the end.
157
00:09:11,960 --> 00:09:14,600
And let's try to build in running once again.
158
00:09:14,780 --> 00:09:16,290
And we can see that.
159
00:09:16,310 --> 00:09:16,910
Let's see.
160
00:09:17,480 --> 00:09:20,090
We can see that five, seven and nine.
161
00:09:20,120 --> 00:09:22,790
These were our previous examples.
162
00:09:22,850 --> 00:09:24,830
So five, seven and nine.
163
00:09:24,890 --> 00:09:29,540
And the maximum equals two nine, which is exactly what we expected.
164
00:09:29,870 --> 00:09:33,480
Let's try to ride once again with some different values.
165
00:09:33,500 --> 00:09:36,470
So five, fifteen and ten.
166
00:09:36,890 --> 00:09:38,600
So the maximum is fifteen.
167
00:09:38,600 --> 00:09:42,110
And it seems that the function is working as expected.
168
00:09:42,170 --> 00:09:48,410
So this is a four of these video guys say, hope you enjoyed it and I'll see in the next one.
169
00:09:48,510 --> 00:09:54,710
We are we are going to talk about another example of function user, just where we are going to return
170
00:09:54,710 --> 00:09:55,550
some value.
171
00:09:55,550 --> 00:09:59,390
And the function also is going to receive sound parameters.
172
00:09:59,800 --> 00:10:02,500
Which something that didn't happen in this example.
173
00:10:02,590 --> 00:10:04,690
So until next time, I'll see you there.
15090
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.