Q.Differentiate between Relational operators and Logical operators.
Relational Operators
Relational operators are used to compare two values in C language. It checks the relationship between two values. If relation is true, it returns 1. However, if the relation is false, it returns 0.
Here is the table of relational operators in C language
| Operators | Operator Name |
|---|---|
| == | Equal to |
| > | Greater than |
| < | Less than |
| != | Not equal to |
| >= | Greater than or equal to |
| <= | Less than or equal to |
Logical Operators
Logical operators are used to perform logical operations. It returns 0 or 1 based on the result of condition, whether its true or false. These operators are used for decision making in C language.
Here is the table of logical operators in C language,
| Operators | Meaning of Operators | Results |
|---|---|---|
| && | Logical AND | True when all operands are true |
| || | Logical OR | True only if either one operand is true |
| ! | Logical NOT | True when operand is zero |
0 Comments