Hey, guys, what's up?
So in this video, we will talk about conditional statements and instructions.
So many time our work is dependent upon some certain conditions if a certain condition is true.
I will do some work if that condition is followed.
I will do some other work.
OK.
For example, let's say I have a variable.
I will take input from the user.
Now I will check.
If A is a good then.
Then I will print.
Let's say hello.
OK, so if Aziga dentin, I will, Brent Hailu.
Otherwise, I will brind worried.
OK, so if Assad didn't condition is true, I will do some work if that condition is false.
I will do some other work.
OK, so let's see.
So let's name this file as if.
If condition.
Nazi BP.
OK, so what do you want to do is I will take a variable, let's say you and I and I will take the volume
input from the user.
Now I will check if the value of A is good.
Then let's have five.
So what I want to do is I will.
Hello.
And similarly, if this condition is fores and that is if I is not good, then five ls.
What we want to do is I want to brand, let's say word.
OK, so.
That's Senate using, okay, sorry.
Name, space.
Space.
OK.
So let's do it again.
OK, so let's say the value of AI is ten.
So Heliers getting Brender.
OK.
So if the value of Iestyn might put it.
Hello.
So as you can see here, this condition is true.
Since this condition is true, I will go inside this records', inside this parenthesis, inside this
Carlip Records and I will print.
Hello.
OK.
So if this condition is true, I will go inside.
I will not be executed because this condition is true.
Let's take one more example.
Suppose the value of AI is, too.
So in this case, my output is wide.
So what happened is the value of FI is to say, I will come here and this condition is false.
Two is not good.
Then five.
So I will not go inside.
OK.
So I will not go inside.
I will come here.
It is.
And I will go inside and will print.
See outweighed.
OK.
So these records.
I had important.
Let's take one more example.
OK, so what will happen if I remove it?
So let's remove it.
Now, let us run it again.
Now, suppose the value of AI is seven and enter is getting rendered?
No doubt, because the condition is true.
I will go inside.
Now, let's say the value of AI is to say nothing is getting Brender, which is obviously correct.
So if the value of AI is to two is not good, then five, this condition is false.
I will not go inside this loop.
I will reach here.
Sorry, it is not a loop.
I will not go inside this if condition.
I will reach here line number 12 and will execute.
OK.
You can also write multiple lines here, for example, see out.
OK.
Similarly, you can ride as and you can do anything.
For example, if you want to change the value of AI, for example, let's say I equals a plus two.
Basically, you're increasing the value if I way too.
And you can print the new value if I hear, for example, see LDI.
OK, so let us know it again.
So let's say the value of fire is five.
So outproduce coming out to be seven because this condition.
Let me show you.
So the value of AI is five.
This condition is false.
I will go inside as so I will increase the value of five by two certainly.
Well if I is seven and I am bringing the value of a simple.
Similarly, if the value of.
I is.
Let's say it.
So these two.
Strings are getting printed.
OK.
Now you can write multiple events condition, for example, let me show you.
So if the value of AI is five.
What I will do.
I will print sea out.
If.
Similarly, if the I'm checking again, elusive.
If I if I say good, then five.
Then I will print out.
In as if.
And let's see else, if about Drugan nations are false.
I will reach in, as I let's say I am branding.
See you out in as.
OK.
OK, I suppose if the value of AI is six, so what will happen, first of all?
I will reach here.
This condition is false.
Now I will check this condition.
Six guerdon five.
Yes.
So output will be in Altuve.
OK, so far I equals six.
Moudud will be in as if.
OK.
So remember out of these T.
Only one of them will run.
OK?
All of them will not be executed.
Only one of all the three will execute.
OK, so four equals six.
My output should be an elusive.
So let's see.
Led to the value of a six mile output is an elusive.
Similarly, let's say, if the value of AI is five, so if the value of five is five.
This condition will be true.
And I will execute this line.
OK.
So these conditions will not be executed.
I will not even check those conditions.
OK.
So if they really if I was five, my output should be enough.
Which is hundred percent correct.
Similarly.
Let's say the value of AI is to sow this condition is false.
This condition is also false because too is not good.
Then five.
So I will reach here in as.
So if the value of AI is to some output, is it as.
OK, great.
So now I guess there is no need there is not compulsion to write as you can also deluded also and there
is no compulsion.
Now, let us try to understand what is the difference between if an elusive.
So what I want to say is.
I can also write like this, if I equals, it equals five.
And here instead of Alice, if I could have written if I had done five.
So I want to check.
What is the difference?
I want to know what is the difference between if and Essive vs..
What is the difference between if and if?
I guess I want to check it.
And I also want to know, can I please as if with if.
OK.
So.
A fascinating if.
Then some court here.
Similarly, if I am writing elusive and checking the condition and then some coded verses, if some
call again if condition and some code, OK.
So I want to find the difference between these two.
So is actually very clear.
Here, either one of them will get executed.
OK?
Both will not get executed if this condition is true.
If this condition is true, this condition will not be checked.
OK.
And here, if this condition is true, this condition will also be checked.
OK, so I will check.
OK, so this is the basic defense.
Let me show you.
So.
Our aim is very simple.
So if so, what I will do?
I will take a variable, let's say, and I will take the value of a input from the user.
And my aim is very simple.
If the value of A is one G-Star value to zero.
And if the value of a zero change the value, a two one.
So this is my book.
OK.
If the value of it is one, make a zero.
Similarly, if the value of a zero make a one.
This is my task that I have to do now with the help of this example, the difference between and NSF
vs..
If if will be very clear.
So let's be clear that.
A.
So if A equals equals one.
So what I have to do with the earlier phase when I have to change the value is to zero.
So equals zero.
No doubt.
Elusive.
And if A equals equals zero.
So if the value of.
And goes it goes zero.
So if the value of a zero, I have to make a equals one.
OK.
So this was the task that I have to perform.
And this is the code.
And finally, I am bringing the value of a.
Okay.
So if I give is one.
So if equals when this condition will get executed, this condition will be true and it will become
zero.
OK.
Since this condition is true, this condition will not be checked.
And I will print zero perfectly fine.
Similarly, if the value of a zero.
So, first of all, I will check this condition, which is false.
Now, this condition is false.
That's why I will check this condition.
OK, so I will check this condition equals zero.
Yes.
The condition is strong.
It will become one.
And then I will bring a.
OK, so this court is fine.
Let's see.
If the value of phase one are virtually zero, good.
If the value of a zero output should be one.
OK.
So this is good.
Now what?
Now what I will do, I will remove this ls.
So I have to conditions.
If.
And if.
OK.
So let's see whether my Arpatepe will be right or wrong.
So let's see.
If the value of phase one, my output should be zero, but it is showing when.
But if the value of a zero day showing one.
So here for the value of equals it all my output is right by four equals one.
My output is wrong.
How?
Let me show you.
So when you are giving a equals zero as input, what will happen?
I will check this condition.
This condition is false.
I will not go inside.
Now, I will check this condition.
This condition is true.
I will go inside equals one and bring the valerian.
So one is getting printed.
Correct answer.
But when it was one, what will happen?
This condition is through.
Since this condition is true, the new value of phase zero.
So A equals zero.
And now what will happen?
I will check this condition.
Is equal zero.
Yes, equals zero.
So it will make a one again.
So it will be again one and then you are printing it.
So one will be printed.
OK.
So this is their defense.
If you're riding, if and if so, this F is independent, this if is independent, both will check the
condition.
But if you are riding, if and else if so, if this condition is false, then only I will check this
condition.
OK.
If this condition is false, then only I will check this condition.
And in this case.
Validus Condition is true or false.
This condition will always be checked.
OK, so there can be many combinations.
You can make many combinations like if only if only if you can write.
A friend is.
OK.
You can also write if.
As if.
And if.
You can ride if it's if it's you can ride if then inside, if then else if then else.
Then inside, as you can, right?
If and so on.
OK, so they had an infinite number of combinations possible.
Now, let's see.
The most interesting thing and most important thing was also.
So I am removing it all.
OK, guys, let's make commander doubt.
My main purpose was to clear the difference between offensive and offensive.
Okay, now the one more thing that I want to make sure I do noise.
Suppose I have a variable in there, which equals one.
And now if.
Five.
A five morde to.
And.
C++.
So if this condition is true, what I want to do is I will print C out.
And if and if block.
And I will bring the value of.
She yelled, led to a.
And if this condition is foys, is what I want to do is.
So what I want to do is I will print sea out.
And as.
And line, and similarly, I will print the value ofthe.
OK.
So virtually my output.
So if the value of phase one.
So not this condition is true.
Five more two is OK.
So let me show you.
So equals one.
OK.
Now, this condition is true.
Why, Drew?
Because five more two is one and one means to any positive value is true.
Zero is false.
OK.
Any positive values true.
And zero is false.
So this condition is true.
But there is an operator.
There's a logical end.
So we will check this condition also E-Plus plus now E-Plus plus plus is Borst.
OK, so first I will check E and then it will be incremental.
So I will check if it is one.
OK.
So both this condition are true.
This is also true.
This whole expression is true.
I will go inside this loop inside this.
Inside this.
Because this is not loop sorry.
Inside this Beckers and Wildwood will be in if.
And what is the value of two.
What does the value of a avil being reminded by events of the new value of phase two.
So my output should be.
And if and do, this should be my output.
Let's see.
OK, so output is enough.
And to.
Now, let's make some minor changes.
So suppose.
If it was.
It is odd.
So what does odysseys?
So what will?
So what will happen?
So I am saying, Hmoud, but we'll be in it if and when this will be my output.
Why?
OK, so five more.
Two is one, which is true, no doubt.
So if this condition is through.
If this condition is true, do I need to check this condition?
No, there's no need to check this condition.
Why?
Because we are having or.
OK, so.
If any of this condition is true.
So if this condition is true, there's no need to evaluate this condition.
This condition will not be elevated because now it is going to be to only.
OK, so a plus plus will not be ulcerated.
So I will go inside this inside this records' and and if and a.
Which is one.
So enough and it will be my output.
OK, so let me show you.
So my output is and if and when.
Okay.
Now, let's do some changes again.
So let's make it six.
Now, see?
So six more.
Two is zero.
Reminder zero.
So this condition is false.
OK.
So since this condition is false, I will check this condition.
OK.
Because this condition is false.
Then I will check this condition.
So E-Plus plus Borst increment first A will be assigned.
Which is one.
So this condition is true.
So this is false.
This is true.
Output is to some output will be an F and two output will be enough.
And two wire.
Because a plus plus statement is evaluated in the last example when it was five more.
Two, this statement was not too elevated because there is no need to do.
Look at that statement because my output is going to be true only.
So in this case, my output will be in effect to.
Let's see.
So in f end, do.
Now, one last thing.
What if.
It is.
Let's see.
And.
So what do leave do?
But if it is and.
Let's see.
So six more two equals zero is false.
OK, so this condition is false.
And we are having and so we will not to look at this condition.
Why?
Because there is no need.
If this condition is true or this condition is false, my output is going to be false only because this
is false.
So my output is going to be false only.
OK.
It doesn't matter whether E-Plus Pleasance true or false.
It doesn't matter.
So this statement, the C++, will not be well written because my output is fixed, which is false.
So I will come here.
My out would really be in as.
And what is the value of a.
The value of phase one.
OK, so Inês and venture boom output.
And as and when.
Now, with the help of these example, we have reached an important desert.
And what is our desert evaluation
of logical expression?
Stops.
As soon as.
Final value.
Is known.
So what I want to say is.
If first condition is false and I am having and and let's say X, so in this case, X will not to be
evaluated, will not be evaluated.
Why?
Because my output is going to be false only.
Similarly, if I am if I am having if through or.
And let's say X condition.
So here also X will not be evaluated.
Why Y.
Because my output is going to be true only.
OK.
So to explain this line, I have taken those examples.
That evaluation of a logical expression stops.
It will stop as soon as the final value is known.
For example, in this case, if the first condition is false.
There is no need to check this condition.
Because my final value's going to be false only similarly if this is true.
There is no need to check this condition because my output is going to be true because of this.
OK, so this is very important.
So I hope this thing is clear.
When a police presence getting evaluated, when it is not getting well rated.
OK.
Thank you.