WEBVTT

0
00:00.070 --> 00:04.890
In the previous video we have learned about logical operators logical operators are used for writing

1
00:04.950 --> 00:06.920
compound conditional statements.

2
00:06.930 --> 00:14.910
We can combine more than one conditional statement by using and or OR example and write a conditional

3
00:14.910 --> 00:17.020
statement and write the program on that.

4
00:17.400 --> 00:19.140
So what is the example here.

5
00:19.150 --> 00:24.060
see Let us take a example off of working hours and leisure hours.

6
00:24.480 --> 00:32.190
So in the daytime the hours starts from zero hour to twenty three hours total twenty four including zero 

7
00:32.190 --> 00:34.240
twenty four hours, total 24 hours are there.

8
00:34.240 --> 00:34.770
now in this

9
00:34.890 --> 00:39.540
from morning 9:00 to evening 6:00.

10
00:39.540 --> 00:41.770
These are taken as working hours.

11
00:41.880 --> 00:47.780
So if I draw a line for 23 hours total 24 hours from zero to twenty three.

12
00:47.830 --> 00:50.160
Now suppose this is 9:00 right.

13
00:50.200 --> 00:58.950
This 9:00 so 6:00 evening will be taken as 18 hours in a 24 hour clock morning 9:00 a.m. to evening

14
00:58.950 --> 01:00.920
6:00 p.m. People do a job.

15
01:01.230 --> 01:05.070
So that job hours are from 9 to 18.

16
01:05.160 --> 01:08.190
So in a 24 hour clock.

17
01:08.380 --> 01:13.500
Now I want to find out weather hour given is a working out or leisure hour.

18
01:13.830 --> 01:16.490
So if I say 10:00, its a  working hour.

19
01:17.160 --> 01:19.760
If I said 12:00 it's working hour.

20
01:20.010 --> 01:24.720
If I say 17:00 then also it is working hour 18:00 clock.

21
01:25.110 --> 01:26.430
Then also it is an working hour.

22
01:26.860 --> 01:28.830
So beyond 18 it's not working hour.

23
01:29.190 --> 01:30.560
So this what I want to check.

24
01:30.990 --> 01:35.610
So for that I have a flowchart here, enter hour read hour.

25
01:35.700 --> 01:42.940
Then if an hour is among 9 to 18 then it should print working hour.

26
01:42.940 --> 01:45.160
Otherwise it should print leisure.

27
01:45.230 --> 01:52.550
means It's not working hour then how to frame a condition that hour should be within this range within this range.

28
01:52.560 --> 01:57.360
So when you have to check something within the range you have to say it is greater than or equal to

29
01:57.400 --> 02:00.620
nine and less than or equal to 18.

30
02:00.630 --> 02:05.910
So there are two figures you have to take, greater than equal to nine means it should be on that

31
02:05.910 --> 02:07.910
side and on this side of 18.

32
02:07.920 --> 02:09.660
So let us write a condition for that.

33
02:09.750 --> 02:11.820
So condition looks like this.

34
02:11.820 --> 02:17.050
If hour is greater than equal to 9.

35
02:17.400 --> 02:25.560
And so AND means this is the operator we use, and hour is less than or equal to 18.

36
02:25.920 --> 02:26.630
Right.

37
02:26.640 --> 02:33.870
So it means in mathematics we write like this, hour greater than equal to nine less than equal to 18.

38
02:33.930 --> 02:38.450
So mostly students will be used to with this one writing this form of mathematical form.

39
02:38.580 --> 02:44.700
But in programming we cannot write the things like this actually these are two different conditions two

40
02:44.700 --> 02:47.040
different conditions and they are joined together.

41
02:47.460 --> 02:53.400
So for both the condition we have to write hour, both the times you have to write and we have to join these

42
02:53.400 --> 02:54.280
two using.

43
02:54.390 --> 03:00.480
And, so when you have to check the range and then you have to write AND you have the right two condition

44
03:00.480 --> 03:02.630
separately make it clear.

45
03:02.760 --> 03:06.590
So you'll come across many times this type of conditions you will come across.

46
03:06.620 --> 03:07.010
Right.

47
03:07.110 --> 03:10.900
When you have to convert them into a program you have to convert it like this.

48
03:11.010 --> 03:13.580
So write both of them and join them with

49
03:13.650 --> 03:18.270
And so let us fill up that in flowchart then will convert it into a program.

50
03:18.570 --> 03:22.380
So hour is greater than equal to nine.

51
03:22.410 --> 03:30.030
And so I'm not edging C++ operator here in simple English language I'm writing and hour is less than equal

52
03:30.030 --> 03:37.420
to 18 that's all,  if this true it will print working otherwise it will print leisure.

53
03:37.780 --> 03:39.890
Now let us convert that into a program.

54
03:40.020 --> 03:43.180
So already I have prepared a few statements in the program.

55
03:43.180 --> 03:48.480
See the main function in this program we need first thing that is one variable so we should declare

56
03:48.490 --> 03:55.570
the variable then I have a message enter hour then reading hour,  reading hour.

57
03:55.890 --> 03:59.600
Now I have to display the working or leisure.

58
03:59.670 --> 04:09.320
So here I will write down the condition if r is greater than equal to 9 and this is in C++ right.

59
04:09.540 --> 04:20.030
or is less than equal to 18 then I should print a message that is working.

60
04:20.640 --> 04:22.620
This can be inside flower bracket.

61
04:22.680 --> 04:32.680
But if you have a single statement you can skip it then else C out here it's leisure right.

62
04:33.990 --> 04:35.720
This is leisure that's all.

63
04:36.690 --> 04:38.230
So this is the program.

64
04:38.670 --> 04:43.020
So this is a simple program using compound conditional operations.

65
04:43.050 --> 04:46.840
So in the next video you will find one more example on this one.

66
04:46.950 --> 04:49.430
Then I have some coding exercises.

67
04:49.430 --> 04:54.540
So in some coding exercise I am asking you to write on this condition and in some coding exercise you

68
04:54.540 --> 05:00.140
have to write on most of the code in a function, maybe you have to write other things from here to

69
05:00.140 --> 05:05.850
to hear in coding exercise that is only a conditional statement and then printing something.

70
05:05.850 --> 05:07.620
So there is a demo available for this one.

71
05:07.620 --> 05:10.790
You can watch that demo and practice the program by yourself.