Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,300 --> 00:00:05,760
All right, so now once you've given it a try on your own, let's solve this exercise together.
2
00:00:06,240 --> 00:00:09,420
So first of all, we know that the function does not return anything.
3
00:00:09,450 --> 00:00:11,580
So it's going to be a fee void type.
4
00:00:11,610 --> 00:00:12,570
So void.
5
00:00:12,600 --> 00:00:16,740
And now we will specify the function name, let's say Marks Legia.
6
00:00:17,340 --> 00:00:17,550
Right.
7
00:00:17,580 --> 00:00:23,350
Because we find out what is the maximum digit between the digits in a given number.
8
00:00:23,960 --> 00:00:27,690
And of course, we are going to receive as a parameter in other a number.
9
00:00:27,720 --> 00:00:35,340
So in Nahm and now we are going to specify the functions body so the body will have to check out some
10
00:00:35,340 --> 00:00:39,690
condition to make sure that the number E has only two digits.
11
00:00:40,020 --> 00:00:44,460
And one way to do it is to use condition like this.
12
00:00:44,520 --> 00:00:52,360
So we know that all the numbers that have two digits are in the range between 10 and 99.
13
00:00:52,470 --> 00:00:52,820
Right.
14
00:00:53,100 --> 00:00:56,940
Something that is less than ten is contains only one digit.
15
00:00:57,210 --> 00:01:03,420
And something that is above some number that is above 99 contains three numbers at least.
16
00:01:03,510 --> 00:01:07,320
So we are going to write a condition that will check this out.
17
00:01:07,350 --> 00:01:10,620
So if NUM is greater than 99.
18
00:01:10,790 --> 00:01:11,100
Okay.
19
00:01:11,220 --> 00:01:11,730
Let's do it.
20
00:01:12,030 --> 00:01:13,900
This is greater than ninety nine.
21
00:01:13,980 --> 00:01:17,000
Meaning it has three digits or.
22
00:01:17,140 --> 00:01:17,620
Or.
23
00:01:18,000 --> 00:01:18,270
Right.
24
00:01:18,300 --> 00:01:26,370
We are going to use this logical operator to see if another condition may happen.
25
00:01:26,380 --> 00:01:32,940
So if NUM is less than 10, which means that we have only one digit.
26
00:01:33,480 --> 00:01:38,490
So if that's the case we are going to print out a corresponding measure message.
27
00:01:38,580 --> 00:01:44,260
The number, the number is not a two digits number.
28
00:01:45,060 --> 00:01:47,340
Please try again or something like that.
29
00:01:48,300 --> 00:01:49,170
Is that clear?
30
00:01:49,260 --> 00:01:55,920
And now what we are going to do is to specify the L section, which means here are all the interesting
31
00:01:55,920 --> 00:01:59,220
stuff that is going to happen, will be here.
32
00:01:59,310 --> 00:02:05,460
So we want to check out if we have two digits number meaning the number itself.
33
00:02:05,700 --> 00:02:09,760
He has X and Y, let's say X is a digit.
34
00:02:09,790 --> 00:02:10,810
And why is it digits?
35
00:02:10,830 --> 00:02:11,100
Right.
36
00:02:11,130 --> 00:02:13,800
For example, let's say thirty five.
37
00:02:14,400 --> 00:02:18,510
So three is a digit is the left digit than five is the right digit.
38
00:02:18,540 --> 00:02:21,840
So we need to compare between these two digits.
39
00:02:22,590 --> 00:02:30,210
And one way to do so is simply to compare the remainder that you will get.
40
00:02:30,450 --> 00:02:32,520
If you divide the number by ten.
41
00:02:32,550 --> 00:02:35,580
So if you do it like this, you will get.
42
00:02:35,610 --> 00:02:40,380
What is the remainder would be if you divide thirty five by ten.
43
00:02:40,770 --> 00:02:44,550
So if you divide thirty five by ten, you will get three.
44
00:02:44,790 --> 00:02:45,150
Right.
45
00:02:45,210 --> 00:02:49,780
Meaning three times you have multiplied by ten will give you 30.
46
00:02:50,040 --> 00:02:52,950
So the remainder in this case will be just five.
47
00:02:52,980 --> 00:02:59,250
So these division, the remainder of by when you divided by ten will be just five.
48
00:02:59,280 --> 00:02:59,640
Right.
49
00:03:00,000 --> 00:03:05,750
Which give you and which gives you the right digit in these two digits number.
50
00:03:06,240 --> 00:03:11,310
So you compare this one to number divided by ten which gives you.
51
00:03:11,940 --> 00:03:15,150
Which is simply the left digit.
52
00:03:15,270 --> 00:03:15,570
Right.
53
00:03:15,630 --> 00:03:22,230
If we said that we divide thirty five by ten in the full day vision like we can see here will you.
54
00:03:22,260 --> 00:03:24,510
Just three which is the left digit.
55
00:03:24,870 --> 00:03:27,930
So that's how you find out the right digit.
56
00:03:27,990 --> 00:03:33,540
And that's how you find the left digit in a number with two digits.
57
00:03:33,600 --> 00:03:38,760
So if that's the case then we know that the right digit is greater than the left digit.
58
00:03:39,120 --> 00:03:47,060
And in this case, we are going to print out the at the maximum maximum digit in percentage.
59
00:03:47,400 --> 00:03:52,030
The number itself we are going to specify it is percentage.
60
00:03:52,890 --> 00:03:54,920
And instead of the first percentage of the.
61
00:03:54,940 --> 00:03:56,130
We're going to specify.
62
00:03:56,640 --> 00:04:01,650
And in the second percentage, would B, we are going to specify the right digit.
63
00:04:01,740 --> 00:04:07,450
The right digit between the two and the L section is pretty, pretty and pretty much the same.
64
00:04:07,470 --> 00:04:14,190
Because we know that if the left the right digit is not greater than the left, then meaning that the
65
00:04:14,190 --> 00:04:17,700
left is at least equal to or greater than the right.
66
00:04:17,760 --> 00:04:24,450
So we are going to copy and paste this line, this line right here.
67
00:04:24,480 --> 00:04:29,630
And instead of nine divided with the remainder, we are going to divide it just by 10.
68
00:04:30,340 --> 00:04:31,830
And that's basically it.
69
00:04:32,160 --> 00:04:33,600
That's the whole exercise.
70
00:04:33,600 --> 00:04:39,210
A try to summarize it and to make it a little bit faster than the previous ones.
71
00:04:39,240 --> 00:04:43,110
So let's write the main section and make sure that the program works.
72
00:04:43,150 --> 00:04:49,110
OK, so let's test it out just by using mongst digit four thirty five.
73
00:04:49,560 --> 00:04:51,900
And let's see what will be printed out to the screen.
74
00:04:51,990 --> 00:04:53,220
So build and run it.
75
00:04:53,310 --> 00:04:54,900
Let's build and run it.
76
00:04:55,050 --> 00:04:58,590
And we can see that the maximum digit in thirty five is five.
77
00:04:59,770 --> 00:05:05,170
We do another example, let's say 98, whoops, sorry about that.
78
00:05:05,710 --> 00:05:07,510
Let's build in a running once again.
79
00:05:07,710 --> 00:05:09,630
Oh, sorry, sorry, sorry.
80
00:05:09,640 --> 00:05:11,290
We should just modify it here.
81
00:05:11,290 --> 00:05:12,400
So 98.
82
00:05:12,550 --> 00:05:14,900
We are going to see it right here.
83
00:05:15,010 --> 00:05:15,240
OK.
84
00:05:15,580 --> 00:05:19,450
So 98, the maximum digit is nine, of course.
85
00:05:19,930 --> 00:05:23,740
And we can see that a program works, that the function works as expected.
86
00:05:24,730 --> 00:05:28,570
You could write longer are more accurate.
87
00:05:28,600 --> 00:05:30,850
Let's say main program.
88
00:05:30,880 --> 00:05:34,750
Just be reading the value from the user as we've done in the previous challenges.
89
00:05:35,020 --> 00:05:39,670
But that will also be OK for now just to make sure that the function of works.
90
00:05:39,850 --> 00:05:46,570
So to summarize, what we've done here is we simply received a number make made sure that this number
91
00:05:46,570 --> 00:05:48,880
has contains only two digits.
92
00:05:48,910 --> 00:05:52,450
And then we compare at between the right digit.
93
00:05:52,600 --> 00:05:53,770
This is the right digit.
94
00:05:54,040 --> 00:06:00,340
And this is the left digit and printed out a corresponding message based on the result of these conditions.
95
00:06:01,000 --> 00:06:02,860
So thank you guys for watching Gehlen.
96
00:06:03,060 --> 00:06:05,440
I'll see you in the next challenge.
8583
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.