The document discusses relational and logical operators in programming. [1] Relational operators like ==, !=, <, >, <=, >= are used to compare two values and return a true or false result. [2] Logical operators like &&, ||, and ! are used to combine multiple conditions. [3] Relational operators are commonly used with if/else conditional statements to test conditions, while logical operators allow combining conditions using AND, OR, and NOT operations.
2. Relational Operators
● Compare two values
Result
1 True
0 False
● Six Operators, No space between the operator
Operator Meaning
== Equal to
!= Not Equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
www.eshikshak.
co.in
3. Relational Operators
● If arithmetic expression on either side of relational
operator, than arithmetic expression will be
evaluated first and then the results are compared.
● All of these operators are known as binary operator,
as they required two expressions as operands.
● They are used with condition statements
www.eshikshak.
co.in
4. Example
● if ( value == 0 )
●{
● printf (“The value you entered was zero.n”) ;
● printf(“Please try again.n”) ;
●}
● else
●{
● printf (“Value = %d.n”, value) ;
●}
www.eshikshak.
co.in
5. Relational Operators
Expression Meaning Result
5 == 3 5 is equal to 3 0
5 != 3 5 is not equal to 3 1
5>3 5 is greater than 3 1
5<3 5 is less than 3 0
5 is greater than or equal to
5 >= 3 1
3
5 <= 3 5 is less than or equal to 3 0
www.eshikshak.
co.in
6. Logical Operator
● Sometimes we need to test multiple
conditions in order to make a decision.
● Logical operators are used for combining
simple conditions to make complex
conditions.
www.eshikshak.
co.in