---
title: 3.8 Relational Operators
description: "Relational operators compare two values and produce an integer result. The result is `1` when the relationship is true and `0` when it is false. ``` #include int main() { int a = 10; int b = 20; printf(\"a <…"
url: "https://edcret.in/docs/c-programming/operators-and-expressions/3-8-relational-operators/"
updated: "2026-09-07"
category: C Programming / Operators and Expressions
---

# 3.8 Relational Operators

Relational operators compare two values and produce an integer result. The result is `1` when the relationship is true and `0` when it is false.

```
#include <stdio.h>

int main()
{
    int a = 10;
    int b = 20;

    printf("a < b  : %dn", a < b);
    printf("a > b  : %dn", a > b);
    printf("a <= b : %dn", a <= b);
    printf("a >= b : %dn", a >= b);

    return 0;
}
```

### Example Output

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

### Explanation

The relational operators are:

| Operator | Meaning |
| --- | --- |
| `<` | Less than |
| `>` | Greater than |
| `<=` | Less than or equal to |
| `>=` | Greater than or equal to |

For example:

```
a < b
```

compares `10` with `20`. Since `10` is less than `20`, the expression produces `1`.

Similarly:

```
a > b
```

is false, so it produces `0`.

The result of a relational operator has type `int` in C and is either `0` or `1`.
