In the previous video we have learned about logical operators logical operators are used for writing
compound conditional statements.
We can combine more than one conditional statement by using and or OR example and write a conditional
statement and write the program on that.
So what is the example here.
see Let us take a example off of working hours and leisure hours.
So in the daytime the hours starts from zero hour to twenty three hours total twenty four including zero
twenty four hours, total 24 hours are there.
now in this
from morning 9:00 to evening 6:00.
These are taken as working hours.
So if I draw a line for 23 hours total 24 hours from zero to twenty three.
Now suppose this is 9:00 right.
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
6:00 p.m. People do a job.
So that job hours are from 9 to 18.
So in a 24 hour clock.
Now I want to find out weather hour given is a working out or leisure hour.
So if I say 10:00, its a working hour.
If I said 12:00 it's working hour.
If I say 17:00 then also it is working hour 18:00 clock.
Then also it is an working hour.
So beyond 18 it's not working hour.
So this what I want to check.
So for that I have a flowchart here, enter hour read hour.
Then if an hour is among 9 to 18 then it should print working hour.
Otherwise it should print leisure.
means It's not working hour then how to frame a condition that hour should be within this range within this range.
So when you have to check something within the range you have to say it is greater than or equal to
nine and less than or equal to 18.
So there are two figures you have to take, greater than equal to nine means it should be on that
side and on this side of 18.
So let us write a condition for that.
So condition looks like this.
If hour is greater than equal to 9.
And so AND means this is the operator we use, and hour is less than or equal to 18.
Right.
So it means in mathematics we write like this, hour greater than equal to nine less than equal to 18.
So mostly students will be used to with this one writing this form of mathematical form.
But in programming we cannot write the things like this actually these are two different conditions two
different conditions and they are joined together.
So for both the condition we have to write hour, both the times you have to write and we have to join these
two using.
And, so when you have to check the range and then you have to write AND you have the right two condition
separately make it clear.
So you'll come across many times this type of conditions you will come across.
Right.
When you have to convert them into a program you have to convert it like this.
So write both of them and join them with
And so let us fill up that in flowchart then will convert it into a program.
So hour is greater than equal to nine.
And so I'm not edging C++ operator here in simple English language I'm writing and hour is less than equal
to 18 that's all, if this true it will print working otherwise it will print leisure.
Now let us convert that into a program.
So already I have prepared a few statements in the program.
See the main function in this program we need first thing that is one variable so we should declare
the variable then I have a message enter hour then reading hour, reading hour.
Now I have to display the working or leisure.
So here I will write down the condition if r is greater than equal to 9 and this is in C++ right.
or is less than equal to 18 then I should print a message that is working.
This can be inside flower bracket.
But if you have a single statement you can skip it then else C out here it's leisure right.
This is leisure that's all.
So this is the program.
So this is a simple program using compound conditional operations.
So in the next video you will find one more example on this one.
Then I have some coding exercises.
So in some coding exercise I am asking you to write on this condition and in some coding exercise you
have to write on most of the code in a function, maybe you have to write other things from here to
to hear in coding exercise that is only a conditional statement and then printing something.
So there is a demo available for this one.
You can watch that demo and practice the program by yourself.