So let's change this, let's try and get it to just around this, so if I say.
Let's actually change these variables, so.
I to say I want is five I two is 10, five is not greater than or equal to two.
So let's go ahead and run this.
And I want to change this to.
Say that again, and I'm actually coming to this compile, it helps run it.
And you notice now it only says i1 is not greater than or equal to i2 because this was false.
So when it saw that this was false, basically skipped over this, these curly braces, whatever in
between these curly braces and went to here and it saw the else and I said, OK, this was false.
I'm going to run whatever is inside of the ealth, and it ran this line right here.
All right, so pretty cool now we have a means to kind of do one thing if something's true and if it's
not true, if it's false, and then we can do this other separate thing.
So you can see how this can be pretty handy to implement some logic in your code.
So now let's look at something called the health if.
So that's kind of like the LS, but it's whenever this is false.
Maybe we don't want to just immediately jump straight to printing this out.
Like some else condition, maybe when we realize that this is not true, we're like, Hmm, OK, well,
this isn't true, but what if now I want to check if something else is true about about these like?
It doesn't have to be about these variables, but maybe you want to check for another condition.
All right.
Well, this failed.
It's false.
But now I want to check for something else to see if that is true and then I can print something out.
So you can say, like are not true.
You know?
And but then maybe your let's see I one greater than.
I want greater than I three try and make an interesting example here, so I won and I three again,
they're both five, so I'm like, Hmm.
So I won greater than nine three.
Well, it's not going to be because they're both five.
But then I say, all right.
Or else if I won equal to three
and then I shouldn't put.
Not true here.
Sorry.
It's cool.
It's true.
And then maybe here, like, OK, at least at least this one is true.
Oh, oh, so
so I oriented.
Let's do that.
OK, so now we kind of expanded upon it.
So we have this if right here.
If I one is greater than I three.
So we have these are both five, you know, this, if this was true in print this out, but it's not.
So then it goes down to here on 18 and it says, All right.
This is the thing that was above me.
Was false.
So whatever was above the elusive was false.
So it made it to here and now it's going to check another condition and says, OK, is I one equal to
three?
And it is right there, both five, so it'll goad into the block of code here with these curly bases,
and it will run whatever's in between the curly braces, which right now it's just one line and say,
Oh, OK, at least this one's true and it will print it out and we'll put it in line there as well.
If this happened to also be false.
So I'll say this is false.
Then it checks this and this is false, too.
Then I'll just go down here and it will just run this else.
All right, so let's go ahead and test this out.
So it does, OK, at least this one is true.
So it ended up coming to here because this was true, this was false and said, All right.
Not going to be able to run.
There's going to have to go down to the next part.
So I pass these little curly braces and I go to here, says elseif.
OK, that means I'm going to check another condition.
So what's what's the condition in here?
I want equals equals I three.
So are they the same?
Hmm.
They're both five.
Yeah, that's the same thing.
So I'm going to enter inside of the curly braces.
I'm going to do whatever is in here which says to printout out, OK, at least this one is true.
Now, let's say, you know, chances to not equal, so if it's greater than else, if I were not equal
to three, which you know is false, they are equal.
So what's going to happen now?
So it ended up coming down here because this was false and it's like, Oh shucks, I got to come down
here and it came to this and it said, Oh, this is false, too.
So then it came down and it said, Oh, that's just me, and I'm going to run this no matter what,
in between here.
And it went ahead and it ran this print in this.
So a cool thing is that you are not limited to having one elf in between the if in the Elf, you can
have multiple conditions that you check.
So you can say if I one equals equals five.
Then you could say, yeah, cool, it's easy.
It's equal time to five.
So this is another LCF condition that I can throw in here.
So go ahead and say this.
And it does cool, it's equal to five because it is equal to five.
Right?
Another important thing to notice, though, is what happens if.
This is sorry if this is true, but then what if this is also true?
What happens then, let's go ahead and just test it out, and then I'll explain some changes back to
equal equal, right?
Because I want is equal to five and it's basically five is equal to five, I want is equal to three.
And then we're kind of saying the same thing here, but differently, we're saying, I want equal equal
five.
So this is true, but this is also true.
So let's see what actually, Prince.
So only this one printed cool, it's equal to five.
This one did not print, even though it was true.
So look, it is, why did that not print?
Well, the reason it didn't is because it stops at the first thing.
That is true.
So if this first if is false.
So check this out.
It's false.
It says, OK, I'm going to the next one, and it says this is true.
It says, Oh great, I'm going to run what's in here.
And then once I'm done running, what's in here and I get to this, I'm just going to skip over all
the next Ellsworth's and ELSS and go to down here.
And just see whatever's next.
Because once one of these is true, it just does it and it doesn't do the rest.
If you want multiple things.
To be able to.
Run.
You need to like if multiple, if you want multiple conditions to be able to run like this is true.
And this is also true and you want them both to print, you do not want to use the else if you just
want to use the if by itself, because there is no else, there is no otherwise.
You're not doing like an otherwise thing in either either or kind of thing like you just do the LCF
kind of imply it's like, OK, I just want you to, you know, do exclusively do one of these.
But if you want them to potentially do multiple ones, then you need to leave it as an if.
So if I change this back to if then it only looks at this one.
Chunk without considering the rest of like them being connected.
It's almost like a standalone question.
It's like if you ask someone.
You know, OK, is this is the sky blue.
And they're like, yeah, it's blue, and then so the next question that you had in line was, is the
sky, not blue?
And like logically, you don't need to even ask that question anymore, right, because someone already
told you the sky is blue, so why ask if it's not blue?
It's blatantly blue.
That's kind of like an LCF mentality like, you know, I'm having a look at the next one or something
like that.
But but if you're just doing the if it's kind of just looking at one question at a time without considering
the next questions, like, is the sky blue?
That's all I care about answering this guy blue.
And it's like, Yes, the sky is blue and you're like, OK, I don't even I'm not even thinking about
what that answer means in the context.
I'm just going to go to my next question What's the next question?
Is the sky not blue?
And you just ask the question again?
Seems kind of a ridiculous example, but it's kind of the analogy that popped into my head at one so.
If you want to ask these kind of independently and run the code solely, run the code inside solely
based on this one condition not linked to anything else, then you can put these efforts.
So let's go ahead and try this.
Now this, you're probably wondering what happens with the elephants in the relationship with the health?
Now the else is just attached to the if it's above it.
So basically, if this is false, this will run.
But you know this if in this, if are independent of each other.
Same with this.
They're all independent of each other.
They're all just going to run this code solely if this is true.
There's no like exclusively only running one thing.
Let's go ahead and save it and run it.
So now we see that cool, it's equal to five and that, OK, at least this one is true, right?
Because those were both to I want is equal to five, and I want to equal that three because I three
is also five.
Cool.
So I'm going to go ahead and change these back.
So if I have this is an elusive as well, it will not.
You know, I don't need these to both be Alsace for only one of them to run.
The fact that I just believe this is an LCF, it's exclusively, you know, kind of has to be one of
these.
So this is false.
It'll check this, but if this is true, it's just going to skip over these next two ones because now
they're kind of all connected.
So once one of them is true, it just bails on the rest of them and skips over the rest of them because
now they're kind of all in a line, it's an f elseif else.
This is true.
So it is not going to care about this or this, it's just going to be like, All right, cool, is he
going to five?
I printed that I got here.
I'm going to skip over these because this is an elusive and else.
I don't need to look at this.
Let's go ahead and prove that.
So you notice that it just prints cool.
It's equal to five.
So we ran it, and it only printed that even though this was true, it did not print it.
Same thing if I change this tune and it's basically just starting it here at this point and now they're
all connected together.
Right here, so if this is true, it wouldn't run any of the rest of this.
If this is true, it's not going to run any of the rest below it.
You know, if this is true, it's not going to run any of the rest below, it should just be there.
So that's kind of how it works with the elusive.
OK, so definitely pretty cool concept, really powerful.
Good thing to know how to use, you're going to use a ton of this logic inside of your programs, and
there are some ways to condense this which we will talk about in future lectures.
You don't have to have so much code.
You can actually kind of condense all of it into a single line.
That's something that you might have already noticed and see life.
And I think I actually showed you you didn't really go into it much, but I think I showed you in the
Sea Lion lecture about just using sea lion in general, that it gives you a little light bulbs and it
gives you the option to condense all this.
Into something called say, it's hard to fly all this dynamically like that, but it'll highlight all
this.
I'm sorry it'll take all of this thinking condense into something called a ternary, and that's just
kind of a nice thing and sea lion that it can do for you.
But we'll talk about 10 days later and no need to talk about squishing the code to something smaller
quite yet when we're really just trying to get our wrap our minds around this concept, right?
So there are some more operators that we will need to go over.
This is kind of a lengthy lecture, so I'm not going to dive into those right now.
We kind of just covered the highlighted ones here, but we need to look at adding numbers, subtracting
numbers, dividing them, and that opens up a whole new class of operators called arithmetic operators.
So kind of like math operators, these are math to right, but they're like logical math kind of like
discrete math if you take in that proposition of logic and all that stuff.
We're also going to look at those arithmetic operators, though, because those are really important,
right?
We need to like multiplying and divide things because a lot of times we're dealing with like numerical
data in programming, right?
So we'll have to do that in another lecture because I don't want to just go forever and ever and stuff
too much into your brain with one lecture, but definitely practice these as much as you can mate train
compound like larger conditions.
With what I mean is put more stuff in here, so like put parentheses around things like this and and
in all them together and just experiment and see if you can see like what the most complex line of logic
you can make is.
So make a bunch of variables and be like parentheses.
I want greater than equal to three and this or that.
You know, and try and really put them all together.
So one thing, though, actually hopefully you haven't failed already on the lecture I do.
I just realized I do want to point out one more thing that is pretty interesting and important, and
that is kind of what happens.
I'm going to go ahead and delete this.
The LCF.
I.
So I'm just going to leave this Earth, and something that's kind of interesting is.
What an integer really holds is a Boolean value.
So we have some integers here, but there's something kind of interesting about C++ where I can you
know how I just put b one in here, like if B one?
And it was it was true.
So it evaluated whatever it was in between this parentheses to true and it ran it, and that's just
because the Boolean held the true value.
So it was the same thing as making some type of statement like larger statement that evaluates to true
or false, right?
You can actually just put the integer in here, though, which is kind of weird.
So I can just put I in here.
And let's go ahead and save this and run it.
And to see what happens in this year, so I'm going to compile this, I'm going to run it.
Weird enough.
It prints cool, it's true here.
And when I literally just put I want in here and this is pretty funky, right, because I want it's
just a number, it's just asking if it's like if five, I mean, that doesn't make any sense, right?
If you say that to someone, I mean, five is not a true or a false.
But it actually is in C++, the way the C++ looks at it is anything that is not a zero.
Is evaluated in a logical sense.
To True.
So I can't even put the number in here.
I don't need to put I one I one has a value five, but let me just put the value five directly into
here by compile it again.
I've already saved it and I run.
It is still prince.
So what I said was that it basically evaluates everything that's not zero to true if it's an integer,
so I'll put a zero in here and I'll show you that right now.
You notice nothing prints now because it's zero.
So interesting enough, it's not only these positive numbers like you can put a negative five here.
So this is signed, right?
I save it, run it.
It even prints out for that when I put it negative five in there.
How weird was that?
And it's kind of like, you know, we'll talk more about these operators and stuff like this.
So here, let me do it.
I four equals negative five.
Let's do an eye for.
You notice that still prints and put aside for hearing is as negative five and still prints, so any
new integer that is not a zero is seen as true.
So that's something interesting to remember to remember.
We also have these like, you know, chars see,
makes char variables.
And I'll just say char.
A equals a, you know, kind of weird, but.
Let's just say.
I put a in here, so if a.
And you notice this still, Prince, because it's looking at that no value of a when you look at like
the Askia, the ASCII table member that showed you hex numbers that have to deal with it and decimal
numbers.
So when I say deal with it, I mean, like the character that you press on the keyboard.
It also has a numerical value assigned to it in hex and a numerical value assigned to it in decimal.
Those things can all be translated back and forth.
Think about this as like it's looking at that decimal value.
As well, and you notice that we just said that things that are not zero are just evaluated to true
like numbers that are not zero are evaluated true here.
So that's why it still is evaluating whatever is in between the parentheses to true.
And so it's printing this.
So that's something interesting.
I just want to point out before we in the lecture that it's not just limited to only putting the Boolean
variable in here, it's really whatever the C++ language considers true or false in between these.
Parentheses, it's going to use that to evaluate it as to whether it should run the code in here.
OK, so I think that's enough.
I'm going to go ahead and end on that next.
In either the next lecture or a subsequent lecture, we will get into the arithmetic operators, but
go ahead and practice this as much as you can to get comfortable with it.
And with that, I will see you in the next lecture.