Relational Operators in C Programming
Relational Operators in C Programming
Introduction to Relational Operators
Relational operators in C programming are used to compare two values or variables. These operators help in decision-making by returning true (1) or false (0).
Relational operators are widely used in conditions, loops, and logical expressions.
List of Relational Operators
Common Relational Operators
==Equal to!=Not equal to>Greater than<Less than>=Greater than or equal to<=Less than or equal to
Example of Relational Operators
int main() {
int a = 10, b = 5;
printf(“a == b: %d\n”, a == b);
printf(“a != b: %d\n”, a != b);
printf(“a > b: %d\n”, a > b);
printf(“a < b: %d\n”, a < b);
printf(“a >= b: %d\n”, a >= b);
printf(“a <= b: %d\n”, a <= b);
return 0;
}
Output Explanation
Each comparison returns:
1if the condition is true0if the condition is false
This output is useful in conditional statements like if and loops.
Using Relational Operators in Conditions
int main() {
int age = 18;
if(age >= 18) {
printf(“Eligible to vote”);
}
return 0;
}
Relational operators help in controlling program flow.
Why Relational Operators are Important
Key Benefits
- Used in decision-making
- Help in writing conditions
- Essential for loops and control statements
- Improve program logic
Start Learning C Programming
Practice relational operators to understand conditions and comparisons in C programming.
Summary
Relational operators in C programming are used to compare values. They return true or false and are essential for decision-making in programs.
FAQs
What are relational operators in C programming?
They are operators used to compare two values or variables.
What does == mean in C?
It checks if two values are equal.
What is the output of relational operators?
They return 1 (true) or 0 (false).
Where are relational operators used?
They are used in conditions, loops, and logical expressions.



