Preview

# Relational Operators in C

These operators are used to perform comparison between values in a program. Various relational operators in C language are as follows:

## 1. < [Less Than]

Less Than operator (<) is used to check for whether one value is smaller than another value or not. Result is  1 or 0.

Examples

10 < 3 = 0
3 <10= 1

## 2. <= [Less Than Equal To]

Less Than Equal To operator(<=) is used to check for whether one value is smaller than or equal to another value. Result is  1 or 0.

10 <= 3  = 0
3 <= 10 = 1
3 <= 3   = 1

## 3. > [Greater Than]

Greater Than (>) operator is used to check for whether one value is larger than another value or not. Result is  1 or 0.

10 > 3 = 1
3> 10 = 0

## 4. >= [Greater Than Equal To]

Greater Than Equal To (>=) operator is used to check whether one value is larger than or equal to another value. Result is  1 or 0.

10 >= 3 = 1
3 >= 10 = 0
3 >= 3   = 1

## 5. Equality comparison(= =)

Equality comparison operator (= =) is used to check whether one value is equal to another value or not. Result is  1 or 0.

10 == 3 = 0
10 == 10 = 1

## 6. Not Equal To(!=)

Not Equal to (!=) operator is used to check whether one value is not equal to another value. Result is  1 or 0.

### Example

10 != 3 = 1
10 != 10 = 0

 Program to demonstrate relational operators. Output (Line Wise) #include #include int  main() { int a=10,b=3; printf(“%d”,(a>b)); 1 printf(“%d”,(a>=b)); 1 printf(“%d”,(a

## Best Books of Computer Science

Lesson tags: compare values in c, comparison operators of c, relational operaotors of c
Back to: C Programming Language