Let's go ahead and try some other things, so we have these volumes here.
Let's kind of mess around with the ebullience.
So remember that the.
Thing inside of the parentheses just needs to evaluate to true or false.
That is the rule.
So that's what these conditional statements are based on this called conditionals because it's a condition
in which it's true or which is false.
So a boolean itself kind of already evaluates to true or false because we're storing the literal value.
True or false inside of the variable, right?
So I could simply just use the Boolean as a condition.
Like, for example, be one is true.
So that's kind of saying like if?
And then whatever is in between here needs to evaluate to true or false, if true, so whatever is in
between here is true right now because it's be one.
Now, as a value trousseau, it will execute the code here if it's B2.
It's false and it will not execute the code here, so I'm going to control TSS.
And actually, before I do that, I should say, you know, I'll change this.
B2 is true or P1 billion is true.
So let's save that and then going to go compile it, run it.
And we noticed that this out P1 is true.
But what if I go here and I say B2 and I say, I change this?
You don't need to change this, but I'm just changing it for us to kind of be able to refer to what
we're talking about.
So if I put if B2, that would mean B2 is true if it was true, but it's not.
So we're not going to see anything run here.
So I can tell s compile run it and we don't see anything.
So let's try something else interesting.
So I.
Put the equals and not equals.
We also just have a simple.
Not without the equals, which is an exclamation point, so.
And remember from the last lecture when we were working with just logic and a theory behind it and the
truth tables, remember that not just inverted, whatever the bullying was.
So if you put not true, that means false.
And remember, like the not not true is kind of true again, right?
Because like, not true is false and you put another notch in front of it in terms of back to true.
So if we invert this, B two is false, right?
So if I put an exclamation point before it, it will say if.
Not false.
And it's just inverting this false to a true.
So let's go ahead and let's try this out, see what happens.
So I run it.
All right, copilot, sorry, and then I run it and it actually runs the code in here it says B2 is
to be to really isn't true.
It's false.
Just say not me.
Two is true to print something incorrect in their right.
So not me, too, is true because we too is false.
But regardless, the program, only C++ only cares whether this evaluates to true or false, and it
will run whatever you want in here, so it doesn't really matter what you type.
It doesn't look at the logic behind this.
It just prints it out so that can be flipped.
You also know if you did not be one, you know, be one runs by itself because it's true, remember?
But if we put not be one, it should.
It should not run.
So I'm going to save this file and run it in.
Nothing prints out because not be one, be one is true and not true is false.
So this although it's a false, it does not run the code.
It just goes to here and then it finishes on this one.
All right, so let's move on, we've already looked at not and the equal and the not equal.
So I also let me let me do a couple more things, so you can also compare the true and false right,
just like the logic.
So I'd like to do that too.
So if I say be one, not equal to be two.
What do you think this you think this is going to print out or not?
So think about what this evaluates doing here.
I'll go ahead and say it.
Oh, I'm here compiling and run it.
So you notice that this prints out, not be one, is true.
So we can change this to, like I just say, print stuff, so it's kind of arbitrary.
So what do you think it printed out?
Well, that's because b one is true.
B two is false, and those two things are not equal, right?
And they're not the same thing.
So saying that true is not equal to false.
If you were to, if you say that, that is a true statement.
So since this whole statement is true, it will run whatever's in here.
So same thing if you just said, you know, be one equals true, you know, be one is true.
So if I save this campaign, let's save it, run it, save it, compile it, run it, print stuff.
Actually, this is true because one stores the value true, and we're comparing it to true.
So this whole statement is true.
Therefore, it prints this.
OK.
So I think that's probably enough to explain the billions and these three that we want over here.
Let's talk about these two in here.
So this is back from the last lecture where we talked about or and and so this first one is two pipes.
If you're going to find that on your keyboard, it's like a vertical line.
It.
Could be.
I'm not really sure where it is on your keyboard.
For me, it's kind of over on the buy the entire key kind of to the right and up from the spacebar.
And then this double ampersand right here is four and so or.
And these are the operators for those or operator and operator.
And this is the logical or and logical end.
So let's go ahead and mess around with these.
We can make some bigger statements by using these.
So if I was to say we'll start out with some easy ones, how about that though?
So remember how or and work?
So if I say be one or be two?
What do you think this is going to evaluate to?
So I go up a little bit things see what these are.
Again, and then think back to the last lecture where we talked about and see if you can figure whether
to figure out whether this is going to print or not.
I'll go ahead and read it.
OK, so it does print stuff.
So why does it print stuff?
Because for or that just means that either one of these have to be true for the whole statement to be
true.
So be one is true.
So true or false is true because at least one of them is true.
So what about an end?
Let's go ahead and save this compile and run it.
So you notice nothing prints out for the end, and why is that?
That's because, like we said in the last lecture, for an end, both sides need to be true.
I saw the way the and can be true.
They both need to be true.
So if I was to change this, for example, if I change, be one or worse, they change
it to true and I say this pilot, run it and then you notice it prints because that's true and true.
But I'm going to go back and put this back to false find another way that we could make a true statement
here.
But let's make it a little bit more complicated than just using only the Boolean and an Andre here.
So if I say B one, which is true and then I say and and then I'm put some more parentheses here to
kind of kind of a sub statement within here, and I'm going to say I one equals equals equals five.
So let's think about this for a second.
We did a little bit of stuff like this in the last lecture, but now we're doing an actual code.
So think about what this whole thing evaluates to in here.
Remember how we went over the truth tables and we were able to kind of break more complicated statements
into pieces and solve them?
So what you should do.
Just like in math is go ahead and solve whatever is in the innermost like parentheses here first, so
we'll go ahead and solve what's in the parentheses first.
So what is this?
I1 equals equals five I one is five, right?
So this whole highlighted chunk here can be replaced in your mind when you're looking at it.
Imagine this whole thing is just the word true because this is true, right?
This over here is also true, so true and.
True is true.
So the whole thing is true.
So it'll print stuff.
So let's go ahead and test this theory.
OK, and it does print stuff, right?
So let's go ahead and change this, so what if I say I want to close too?
Now what do you think's going to happen?
So nothing prints, and that is because this is false, right?
And if one side is false and this is false, true and false, it's not true.
Both sides have to be true for that, for the end to be able to make it evaluate to true.
So pretty cool, right?
You can make some pretty complicated lines in here, if needed.
So let's move on to the next one.
So we have the OR and the and of course, you know, maybe practice a little bit too using the or so.
Let's do like you can practice here.
I don't know if I'll do more examples where you can mess around with stuff in here and make like another
sub statement in here like I won and be to equal to.
So it's like false.
And then you could say b two equals.
Like.
B one or B two?
Something like this, you know, doing a practice mess around with the or in the end and telling you
feel pretty confident with those, but I'm going to move on to the next thing here and that is going
to be the.
Less than a greater than sign, so.
And we have a greater than.
So whatever is on the left to be greater than what's on the right, so let's go ahead and try that out.
So if I say I to greater than I one.
And this is really similar to math, so you've probably seen these symbols, you know, greater than
less than greater than or equal to and less than or equal to.
So I'm just going to roll through them just so you feel comfortable.
So here we have I to Kate and I one well, I two is 10 right and 10 is greater than five, which is
stored in won.
So this should print.
And it does so print stuff.
So pretty cool if I go ahead and flip this and save it.
Oops!
You notice it doesn't print because I, too, is not less than I one indicator greater.
So now I flip that sign doesn't work out.
I can also say something like I could put another value in here.
I three equals five and I could say, you know.
I to greater than or equal to a three.
So actually, this is I won, I won greater than or equal to I three, you know, five and five.
So we on that.
It prints stuff because i1 is equal to five, so I want is equal to three, they both have the value
five storing them.
And we said greater than or equal to.
So this could actually be broken down, what's really happening here is something like I want you can
rewrite this as I one greater than I should do this.
I one greater than I three or I one equal to my three.
So essentially, is that the greater than or equal to island, greater than or equal to its kind of
can be broken down like this as well?
So you're saying greater than is island greater than I three or I want, it's equal to three in which
the latter would evaluate here to true, right?
Because I want is equal to three.
And this is false.
Right, because I want to not canonize me, but the fact is, we have an orange here, remember just
one of the side's needs to be true.
So this whole thing is true.
The right side is true.
That means the whole thing evaluates to true.
So when you're doing won greater than or equal to three, it's kind of the same thing, but more shorthand
version of it.
Cool.
So I don't think that that needs to much more of an explanation, you can use this with a lot of things,
a lot of data types.
You can compare floats and doubles and even like charts and things like that.
So if you remember back to the data type lecture, you remember that Charles also can be thought of
in terms of their value, their decimal value and stuff like that.
If you look back to that lecture, when Patricia talking about the ASCII table, the AC III table,
you know, that means that you could compare charges as well as those have those decimal number representations
as well and things like that.
So I think that that is pretty covered.
The next thing that I am going to do is talk about how we can do some extensions on this key word here.
So we have an F..
But it's not limited to just using an F.
And there is also something called else and also something called Elspeth.
And so I'm going to start out with the ealth and see how we can use that in combination with this if.
So.
You could basically right two ifs here, like let's say that.
You wanted.
Let's say let's just pretend that only an air force exists.
There is no else and elusive, and let's say I want to have something different if this is true.
And then I want to have something else print if it's if it's false, right?
So.
Let's just change this in here to say I won greater than or equal to high three.
So how about that?
And then maybe I say, Oh, well, if that's if this is false.
Then I would like to have it not print this, but instead print on, you know, I won.
It's not greater than or equal to E3, something like that.
So you're like, Oh, cool, I'll just put it afterwards, right?
Because if this is false, then it will just go to here.
But the problem is, is that this will run.
Basically.
This thing kind of runs like regardless of whether the condition is, you know.
False.
You know, it's still it's still going to run basically if if it's true, so.
So like I one is greater than or equal to E3, so let's go ahead and run this.
So I'm bringing this up.
So we notice that it does, in fact, print.
I won greater than or equal to three because it is great and it is greater than I thought, or so it
is equal to I three, it's greater than or equal to on its equal to.
So that works.
But then it also runs Line 18, where we said I want is not greater than three.
And that's that's not true, right?
Why are we printing that?
We shouldn't print that because it's true.
We only want to print it if it was false.
And you know, it's still rain.
So we have to find a way to to get this to only run if this is false.
And the way that we can do that is by using this else here and further else, you don't actually need
a condition, you just put the brackets here.
So like the curly braces.
So I'm going to copy this and then delete it, and I'm actually going to put it inside of here.
And remember, you don't have to indent it like I am here.
You notice that there's an indentation here for the code that's inside of the curly braces.
This is just kind of good code in practice to make it more readable since this thing lies inside of
the F basically inside of these curly races.
They are for the if that means that it's a good idea to make it look like it's inside.
In the way to make it look like it's inside is too indented over so that for spaces or a tab.
That's just that just makes it more readable, and in some other languages, this is necessary, it's
like required, so it's kind of nice to just standardize it and.
It'll be more appealing as people read your code and make more sense, you'll be able to look through
it quicker.
So kind of a good idea to make it look nice like this.
So let's get back to the real point, which is that now this will only print.
When this is evaluated to false.
All right, so before this evaluated to True and it printed this, and then we just left this line right
here on Line 18.
And it printed two, which we don't want it to print.
We only want it to print when this highlighted thing in here is false, whatever in between the parentheses.
On the F is false.
So, of course, if we run this again, it's just going to print, you know this, so let's go ahead
and do that.
So I'm going to compile it.
I saved it already.
I'm going to run it.
And you notice now it only prints.
You know, I won greater than or equal to three because it's true, but it doesn't print this other
line that we have right here.
When we you remember, we just used to have it like right here and in print, and now it doesn't.