Hello and welcome to the 14th tutorial on the c++ programming series that is followed we'll be looking at logical operators. So there are three logical operations when we're looking at what is the NOT operator. And that allows you to basically infer something that like not true would become first is the double ampersand operator or this nun, referred to as the AND operator allows you to combine different expressions together and obtain a single result. The and operator checks if all statements evaluated true if one don't evaluate to true then the entire without false statement false then any remaining statements are not checked out it is no longer true. There's the operators it checks if at least one statement is true statement is true, then any remains remains things are not checked as the only record a single statement to be true. We'll also be combining these demos just to show you some really cool stuff.
So let's go ahead Then open up a project so let's get rid of this first operator if not greater STD c STD mine and in here we're going to put not true and it prints out zero aka false. So if we do true you'll print out one. So yeah, listen it for the NOT operator just inverting the wire recedes and you put it to the left of the value variable or what have you. The next operator we're going to be looking at is the an operator which is two ampersands and this and operator let's put this to uppercase so The and operator works like this. So sddc. FTP, and knowing we're going to do does five equal five, which it does.
And then five is greater success with some brackets. So if we run this, this is coming out this one second. One again, we have zero and simple, because first it checks to five equal five. Yes, it does, then it checks though, is far greater next. No it isn't. But because all the expressions need to evaluate true, that's the only way that this entire expression can evaluate to true, therefore is evaluating to false if we just put false It went over evaluate to one.
So, that is it for the AND operator lease literally that simple. So, look at the OR operator now. So that's just these two vertical lines is called OR operator STDs TD line Sorry about that. We're gonna do if, before or not in here we're gonna put four hoof grips on six which isn't. And five less than eight. We run it.
Let's get this one again. We get one first check is five minutes six. Now, because it's the operator only recall one expression to be true for the entire statement to evaluate to true then Check these five less than a a okay for this put true as a change to a free so none of these are true and then evaluates to zero. And now what we're going to do is just show you how you how you can combine these by name and all STDs co STD line in here we're going to be put in does five equal five and seven people eight or greater six or six less than nine Let's put brackets running twice. It will not work. If your results are one, so let's go through what it's done.
It's checked this bracket first and said does fiber fiber? Yes. Good. It says and 270 quid no so this actual statement is false, but it's an all statement here. And that's like you consider that to be the outermost condition check Cosmos operator and they say or does this statement evaluate to true so let's check. First check the progress six note or is six less than nine?
Yes it is. So this statement evaluates to true. Hence, this entire statement evaluates to true. That is It is that simple and easy to use. Logical operators logical operators is something that you will use a lot in your application. Once you know see, see if I was not just c++ M. In most programming language you'll be using these enough operator fine you'll be using less comparatively AND and OR operator, and you probably won't be combining them in certain circumstances.
In the next tutorial we're going to look at the conditional ternary operator. If you have any questions feel free to message us or support sono system calm, okay, the email will be in the description. You can comment on this video or just directly message as well YouTube won't be so comfortable. Also, the source code will be in the description via link and as usual, thank you for watching and I hope you have a nice day.