Using the Relational Operators
Next on our list of operators is going to be the kind known as the relational operators.
Remember that the arithmetic operators we talked about above are responsible for helping us do any kind of mathematical equations that we want inside of the codes, and then the assignment operators are responsible for making sure that all of our variables, or some of the spaces that are reserved in the memory of our computer, will have a good value assigned to them.
But now it is time to shift our focus for a moment and look at how these relational operators work.
First, the relational operators are going to be the best to work with because they can help us have a chance to compare the values of two different operands in the code.
Because we have the ability to make this happen, these are going to be the best to use when we handle some of our conditional statements later on.
There are a number of relational operators that we are able to use in this language.
To make it easier and to really see what is going to happen when we use these, we have to make the assumption from the beginning that d = 100 and e = 150:
If the two values end up being equal, the operand will tell you it is true. Otherwise, the operand will tell you it is false.
For example, saying the d == e would show up as false.
If the values end up not being equal, it will tell you this is true.
For example, e != d would result in a true.
If it is, then the operator will tell you it is true.
For example, saying that e > d would be true.
If it is, you will get it to show up true, such as the formula d < e.
Otherwise, it will tell you the statement is false.
For example, saying that e >=d evaluates as true.
For example, d <= e is true.
One of the things that we need to remember when we work with this particular type of operator is that you will actually end up with a result that is Boolean each time that you want to use them.
What this means is that you will get an answer that is either true or false based on the conditions that you add to that part of the code.
At this time, it is a good idea for us to go through and checking through the code, seeing whether we add in the proper number of equal signs to make this work.
If we are doing the equality operator, there need to be two equal signs; otherwise, we are working with the assignment operator, and that will get us a different result than what we want at this time with all of this.