Comparison operators are used when we want to compare two variables to one another. So for example, we have here two variables. The first one is a and the second one is B. And we want to compare which one is the bigger, I would just type A, and then greater than sign, and then B. And then I would just save and run our program. And I get in our count console.
True, because yes, a is four, which is greater than B, which is three. If I want to check which one is smaller, I would just add a smaller than sign as you can see, instead of the greater than, and I would just save and run our program. And it says here false, because A is greater than B and here it says a smaller than B. But there is a Also another way to check if a number is smaller than or equals. And in that case, we just add the equals sign besides the smaller than or greater than sign, and save our our program and run. And here it says false because A is greater than B, but here, it just checks if A is smaller than or equals b.
But let's change a from four to three. And if we save our program and run it again, we will get through because here it checks if A is smaller than or equals, and he has a equals b, which is true and hence it printed out true. And we could also check if a is greater than or equals b. And if I say from drawn, I am going to get to also because A equals B. But what if we want to check if A equals B just equals, I would just add three equals seven. And if I save and run, I get also true because A equals B, if I change a back to four, and I save again and run, I get false, because a does not equal to b.
And here it says A equals to B. If I want to change, if I want to check, if a does not equal to b, I would change the first I would replace the first equal sign with an exclamation mark and save and run. And I would get through because a does not equal to b and that is absolutely true. So comparison operators are very important when we want to compare two variables to one another. So to recap, we have greater than, we have smaller than, we have greater than or equals, we have smaller than or equal We have equals, we have does not equal