
Operators in C language plays a decisive role in determining the operation that needs to be performed. Basically, an operator is a symbol used in C program that specifies the mathematical, relational and logical operations that is to be carried out on an operand. An operand can be variable or a constant on which an operator works and together forms an expression. The operators on the whole is divided into 10 different categories. The types are as follows :
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Unary operators
5. Equality operators
6. Conditional operators
7. Bitwise operators
8. Comma operators
9. Assignment operators
10. Sizeof operator
Secondly, let's look in for Relational Operators.
RELATIONAL OPERATORS :
Relational operators are also widely known as comparison operators. Its basics and the most crucial job is to compare two values. It returns the value 0 and 1 to the user in a C program after executing its comparison work.
1 represents TRUE
0 represents FALSE
Relational operators too have relational expressions which is an expression that consists of relational operators. The primary mission of this operator is to get to know the user about the inter relation between the operands. There are n number of relational operators, out of which, a few are displayed here.
Relational operators:
'<' represents less than
For example,
2 < 10 returns the output value as 1.
30 < 20 returns the output value as 0.
'>' represents greater than
For example,
10 > 3 returns the output value as 1.
20 > 50 returns the output value as 0.
'≤' represents less than or equal to
For example,
10 ≤ 10 returns the output value as 1.
20 ≤ 10 returns the output value as 0.
'≥' represents greater than or equal to
For example,
50 ≥ 20 returns the output value as 1.
10 ≥ 50 returns the output value as 0.
The evaluation of the relational operators takes place from left to right and the result is displayed as the output i.e., either the value 1 for True or 0 for False. The most interesting fact is that we can also use characters for comparison. It might be surprising!! But it is absolutely true. Since, the characters in a C program are represented by numeric values in a computer system, we can use them for comparisons also.
For instance let's consider the two variables named A and B. Let us also assign values to them. A is assigned the value as 12 and B is assigned the value as 16. Now it's time to introduce our relational operator.
A > B = 0
A < B = 1
A ≥ B = 0
A ≤ B = 1
Here, the characters are compared, but we are getting a result since these characters are assigned values.
At times, there are also chances for us to use arithmetic operators along with relational operator. In that case, a doubt may arise like which one will be executed first? Or what is the precedence order? The answers to these questions are as follows.
First, if an expression comes along its way with both relational and arithmetic operators, initially the arithmetic operator will be executed and then comparison takes place.
For instance consider the operation below.
2*4>5
In a C program, the following step by step execution takes place.
Initially 2 is multiplied by 4 and returns the value as 8. Now the given expression changes to this format.
8>5
Now this 8 is compared with 5 and the result is displayed as 1 which represents TRUE.
Thus arithmetic operators are given higher priority over relational operators.
Have a great day friends!!
Thank you!!
About the Creator
Preethi Siva
Writing is not my hobby.........
It comes when my heart is connected to my soul and says to write!!!



Comments
There are no comments for this story
Be the first to respond and start the conversation.