Relational Operators in C Language


Relational operators in C Language:

    • Relational operators are used to find the relation between two variables. i.e. to compare the values of two variables in a C program.
S.no
Operators
Example 
Description
1
>
x > y
x is greater than y
2
<
x < y
x is less than y
3
>=
x >= y
x is greater than or equal to y
4
<=
x <= y
x is less than or equal to y
5
==
x == y
x is equal to y
6
!=
x != y
x is not equal to y

Example program for relational operators in C language:

    • In this program, relational operator (==) is used to compare 2 values whether they are equal are not.
    • If both values are equal, output is displayed as ” values are equal”. Else, output is displayed as “values are not equal”.
    • Note : double equal sign (==) should be used to compare 2 values. We should not single equal sign (=).

Output:

m and n are not equal



 Continue on types of C language operators:

S.no
Types of Operators
             Description              
1
Arithmetic_operatorsThese are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus
2
Assignment_operatorsThese are used to assign the values for the variables in C programs.
3
Relational_operatorsThese operators are used to compare the value of two variables.
4
Logical operatorsThese operators are used to perform logical operations on the given two variables.
5
Bit wise operatorsThese operators are used to perform bit operations on given two variables.
6
Conditional (ternary) operatorsConditional operators return one value if condition is true and returns another value is condition is false.
7
Increment / decrement operatorsThese operators are used to either increase or decrease the value of the variable by one.
8
Special operators&, *, sizeof( ) and ternary operators
www.cinterviews.com appreciates your contribution please mail us the questions you have to cinterviews.blogspot.com@gmail.com so that it will be useful to our job search community

No comments: