Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

C relation operator

The document provides an overview of operators in C programming, including arithmetic and relational operators. It includes example code demonstrating the use of these operators and their outputs. Additionally, it lists the six relational operators with their descriptions and syntax.

Uploaded by

neeraj.bhopal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

C relation operator

The document provides an overview of operators in C programming, including arithmetic and relational operators. It includes example code demonstrating the use of these operators and their outputs. Additionally, it lists the six relational operators with their descriptions and syntax.

Uploaded by

neeraj.bhopal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1/26/25, 6:19 PM Operators in C - GeeksforGeeks

int main()
5 {
6
7 int a = 25, b = 5;
8
9 // using operators and printing results
10 printf("a + b = %d\n", a + b);
11 printf("a - b = %d\n", a - b);
12 printf("a * b = %d\n", a * b);
13 printf("a / b = %d\n", a / b);
14 printf("a % b = %d\n", a % b);
15 printf("+a = %d\n", +a);
16 printf("-a = %d\n", -a);
17 printf("a++ = %d\n", a++);
18 printf("a-- = %d\n", a--);
19
20 return 0;
21 }

Output

a + b = 30
a - b = 20
a * b = 125
a / b = 5
a % b = 0
+a = 25
-a = -25
a++ = 25
a-- = 26

2. Relational Operators in C
The relational operators in C are used for the comparison of the two
operands. All these operators are binary operators that return true or
false values as the result of comparison.

These are a total of 6 relational operators in C:

https://www.geeksforgeeks.org/operators-in-c/ 4/27
1/26/25, 6:19 PM Operators in C - GeeksforGeeks

S. No. Symbol Operator Description Syntax

1 Returns true if
the left
operand is
< Less than a<b
less than the
right operand.
Else false

2 Returns true if
the left
operand is
> Greater than greater than a>b
the right
operand. Else
false

3 Returns true if
the left
operand is
Less than or
<= less than or a <= b
equal to
equal to the
right operand.
Else false

4 Returns true if
the left
operand is
>= Greater than
greater than a >= b
or equal to
or equal to
right operand.
Else false

5 Returns true if

== both the
Equal to a == b
operands are
equal.

https://www.geeksforgeeks.org/operators-in-c/ 5/27
1/26/25, 6:19 PM Operators in C - GeeksforGeeks

S. No. Symbol Operator Description Syntax

6 Returns true if

!= both the
Not equal to a != b
operands are
NOT equal.

Example of C Relational Operators

1 // C program to illustrate the relational operators


2 #include <stdio.h>
3
4 int main()
5 {
6
7 int a = 25, b = 5;
8
9 // using operators and printing results
10 printf("a < b : %d\n", a < b);
11 printf("a > b : %d\n", a > b);
12 printf("a <= b: %d\n", a <= b);
13 printf("a >= b: %d\n", a >= b);
14 printf("a == b: %d\n", a == b);
15 printf("a != b : %d\n", a != b);
16
17 return 0;
18 }

Output

a < b : 0
a > b : 1
a <= b: 0
a >= b: 1
a == b: 0
a != b : 1

Here, 0 means false and 1 means true.


https://www.geeksforgeeks.org/operators-in-c/ 6/27

You might also like