Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,590 --> 00:00:04,400
So this exercise should be very easy and intuitive for you.
2
00:00:04,550 --> 00:00:10,610
And actually, I hope that you get this video after you've tried to solve this exercise on your own.
3
00:00:10,760 --> 00:00:11,870
You gave it a shot.
4
00:00:12,020 --> 00:00:18,980
You tried to run some commands, even if that doesn't seem to be working out as you expected.
5
00:00:19,400 --> 00:00:21,140
You tried to fix some bugs.
6
00:00:21,170 --> 00:00:24,470
You tried to run these code once again.
7
00:00:24,770 --> 00:00:25,550
And that's OK.
8
00:00:25,610 --> 00:00:26,720
Don't be afraid of it.
9
00:00:26,810 --> 00:00:28,130
That's how we learn, guys.
10
00:00:28,250 --> 00:00:31,130
And now let's go over this solution together.
11
00:00:31,280 --> 00:00:33,830
Basically, this exercise is pretty straightforward.
12
00:00:33,860 --> 00:00:39,860
First of all, we need to understand first the difference, the difference between what is an odd number
13
00:00:39,860 --> 00:00:44,930
and what is an even number and the rule to find it out is as follows.
14
00:00:44,990 --> 00:00:47,930
Basically, if if the number.
15
00:00:48,080 --> 00:00:48,470
All right.
16
00:00:48,500 --> 00:00:51,530
If the number can be can be divided.
17
00:00:51,580 --> 00:00:57,440
I'm writing eating the comments here can be divided by two without a remainder.
18
00:00:57,590 --> 00:00:59,840
Without a remainder.
19
00:01:00,230 --> 00:01:01,280
All right, then.
20
00:01:01,280 --> 00:01:05,750
In this case, the number is going to be an even number.
21
00:01:06,050 --> 00:01:06,410
All right.
22
00:01:06,500 --> 00:01:07,370
And even one.
23
00:01:07,500 --> 00:01:08,630
And even number.
24
00:01:09,470 --> 00:01:10,220
Otherwise.
25
00:01:11,030 --> 00:01:14,540
Otherwise, if the number can not be divided.
26
00:01:14,570 --> 00:01:18,740
If the number can not be divided.
27
00:01:18,890 --> 00:01:22,760
Divided by two without a remainder.
28
00:01:22,880 --> 00:01:23,120
Right.
29
00:01:23,150 --> 00:01:28,670
Without a remainder, then this number is going to be an odd number.
30
00:01:29,060 --> 00:01:34,160
And that's basically the whole difference between these two types of numbers and even number in and
31
00:01:34,160 --> 00:01:35,090
an odd number.
32
00:01:35,510 --> 00:01:45,440
So, for example, if we have for a let's say, for example, example, if we have four, 10, 20,
33
00:01:45,520 --> 00:01:47,480
you know, something like that.
34
00:01:48,170 --> 00:01:54,830
All of these numbers are even because they can be divided by two without having a remainder.
35
00:01:54,860 --> 00:01:55,330
All right.
36
00:01:55,340 --> 00:02:02,330
So all of these numbers are an example, two and even number, even numbers.
37
00:02:02,840 --> 00:02:11,540
And for example, if we have for another example, if we have, let's say, five in 1927, these are
38
00:02:11,540 --> 00:02:18,860
numbers which are odd numbers, because every time, if you will try to divide them by two, then you
39
00:02:18,860 --> 00:02:21,590
will always have a reminder of one, right.
40
00:02:21,620 --> 00:02:26,030
If you divide five by two, then you will get a result of two.
41
00:02:26,120 --> 00:02:29,870
And a reminder of a remainder of just one.
42
00:02:29,960 --> 00:02:30,350
All right.
43
00:02:30,350 --> 00:02:33,500
So these numbers are odd numbers.
44
00:02:34,040 --> 00:02:37,730
So now we know how to classify between odd and even numbers.
45
00:02:38,120 --> 00:02:42,020
And pretty much, I guess you got the idea.
46
00:02:42,050 --> 00:02:48,760
It's not so complicated for those of you who are not so familiar with what are even numbers in odd numbers.
47
00:02:48,770 --> 00:02:52,110
And let's dive to writing or a code in C.
48
00:02:52,250 --> 00:02:54,110
So for that, let's first of all, create.
49
00:02:54,260 --> 00:02:54,660
All right.
50
00:02:54,690 --> 00:02:58,490
Are we I think I will remove these comments that they will not bother you.
51
00:02:58,670 --> 00:03:00,830
I guess you wrote them down also.
52
00:03:01,160 --> 00:03:03,520
So first of all, let's create a variable now.
53
00:03:03,600 --> 00:03:04,860
End now.
54
00:03:05,580 --> 00:03:06,130
All right.
55
00:03:06,140 --> 00:03:08,930
And then we are going to display a nice message.
56
00:03:08,930 --> 00:03:10,700
Print F enter.
57
00:03:11,070 --> 00:03:12,800
Enter a number.
58
00:03:13,190 --> 00:03:13,650
Right.
59
00:03:14,510 --> 00:03:23,030
And then you go scan F percentage D and we are going to read a value to read an integer value and put
60
00:03:23,030 --> 00:03:25,440
it inside in a variable.
61
00:03:25,700 --> 00:03:31,160
And up until this point, everything is similar to the previous sections and exercises that we've seen
62
00:03:31,160 --> 00:03:31,820
so far.
63
00:03:31,910 --> 00:03:37,130
So now we are going to insert our F condition and we are going to use it if.
64
00:03:37,310 --> 00:03:41,360
And here we are going to specify the condition of the checks.
65
00:03:41,480 --> 00:03:47,530
If if the division of NUM over two has a remainder of zero.
66
00:03:47,660 --> 00:03:50,620
And if that's the case, we know that NUM is even.
67
00:03:50,630 --> 00:03:51,070
All right.
68
00:03:51,080 --> 00:03:53,440
So we are going to print a corresponding message.
69
00:03:53,480 --> 00:03:57,230
So print F percentage the is even.
70
00:03:57,590 --> 00:03:58,370
And the backslash.
71
00:03:58,460 --> 00:03:59,460
And here.
72
00:03:59,540 --> 00:04:01,130
And instead of percentage the.
73
00:04:01,160 --> 00:04:06,320
We are going to replace it with the value of nom itself and semicolon in the end.
74
00:04:06,440 --> 00:04:09,950
And the if the conditional result is not true.
75
00:04:10,040 --> 00:04:10,580
All right.
76
00:04:10,670 --> 00:04:12,650
If there is still a remainder.
77
00:04:12,650 --> 00:04:13,070
If we do.
78
00:04:13,160 --> 00:04:15,080
If we divide num by two.
79
00:04:15,140 --> 00:04:16,470
But we got a remainder.
80
00:04:16,490 --> 00:04:17,300
So we use the.
81
00:04:17,330 --> 00:04:18,470
Else section.
82
00:04:18,950 --> 00:04:22,850
And if that's the case we are going to print that phenomena.
83
00:04:22,960 --> 00:04:24,090
Self is odd.
84
00:04:24,170 --> 00:04:24,650
All right.
85
00:04:24,680 --> 00:04:29,060
So percentage the is odd exhibition at the end.
86
00:04:29,250 --> 00:04:33,680
Now pretty much the same line as we of the used right here.
87
00:04:34,670 --> 00:04:35,540
And there you go.
88
00:04:35,630 --> 00:04:37,800
We've written a program that checks.
89
00:04:37,880 --> 00:04:39,980
If a number is even or odd.
90
00:04:40,070 --> 00:04:44,840
And based on the result of the condition, it brings out a corresponding message.
91
00:04:44,930 --> 00:04:46,820
So let's try to run this code.
92
00:04:46,850 --> 00:04:48,320
Let's build and run it.
93
00:04:48,670 --> 00:04:49,790
All right.
94
00:04:50,090 --> 00:04:50,900
There you go.
95
00:04:50,900 --> 00:04:51,800
Enter a number.
96
00:04:52,100 --> 00:04:52,520
Let's see.
97
00:04:52,520 --> 00:04:56,000
We know that, for example, ten should be an even number.
98
00:04:56,090 --> 00:04:59,210
Enter number ten is even rate.
99
00:04:59,390 --> 00:04:59,900
And now let's.
100
00:05:00,090 --> 00:05:04,710
Tried to use something that is odd, for example, five.
101
00:05:05,160 --> 00:05:05,790
There you go.
102
00:05:05,820 --> 00:05:07,020
Five is odd.
103
00:05:07,530 --> 00:05:07,890
All right.
104
00:05:08,760 --> 00:05:10,110
So basically, that's it.
105
00:05:10,140 --> 00:05:12,810
We could just maybe add some message here.
106
00:05:13,430 --> 00:05:18,450
Nahm is an even number to make it more clear.
107
00:05:18,490 --> 00:05:18,890
No.
108
00:05:19,290 --> 00:05:22,620
And also now is an order.
109
00:05:23,190 --> 00:05:26,130
No, just some formality.
110
00:05:26,200 --> 00:05:26,610
All right.
111
00:05:27,030 --> 00:05:29,280
So this is it for these video guys.
112
00:05:29,370 --> 00:05:32,520
And we checked just to summarize everything up.
113
00:05:32,580 --> 00:05:33,180
We checked it.
114
00:05:33,210 --> 00:05:35,250
The remainder is zero.
115
00:05:35,250 --> 00:05:36,960
And based on the result we've printed out.
116
00:05:37,440 --> 00:05:40,240
That's that number is an even number.
117
00:05:40,260 --> 00:05:41,970
Otherwise, it's an odd number.
118
00:05:42,210 --> 00:05:43,320
Another solution.
119
00:05:43,350 --> 00:05:44,790
I will just put it here.
120
00:05:44,850 --> 00:05:52,830
Let's copy and paste that we could have checked if the number has a remainder, which is not zero.
121
00:05:52,920 --> 00:05:58,940
And if that's the case, we are going just to switch places between the print F commands and print that
122
00:05:58,940 --> 00:06:00,030
the number is odd.
123
00:06:00,360 --> 00:06:04,290
Otherwise, it's even even not even.
124
00:06:04,590 --> 00:06:09,090
So that's at least part of code and this part of code.
125
00:06:09,120 --> 00:06:12,300
Basically, they do just the same.
126
00:06:12,570 --> 00:06:16,650
It's just that the condition is formulated a little bit differently.
127
00:06:17,040 --> 00:06:19,140
Here we check for the quality.
128
00:06:19,170 --> 00:06:25,130
And here we check if it if the remainder does is not equal to zero.
9957
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.