---
title: 3.22 Comma Operator
description: "The comma operator `,` evaluates two or more expressions from left to right. The value of the entire comma expression is the value of the rightmost expression. ``` #include int main() { int a; int b; a = (10, 20);…"
url: "https://edcret.in/docs/c-programming/operators-and-expressions/3-22-comma-operator/"
updated: "2026-09-07"
category: C Programming / Operators and Expressions
---

# 3.22 Comma Operator

The comma operator `,` evaluates two or more expressions from left to right. The value of the entire comma expression is the value of the rightmost expression.

```
#include <stdio.h>

int main()
{
    int a;
    int b;

    a = (10, 20);

    b = (1, 2, 3, 4);

    printf("a = %d\n", a);
    printf("b = %d\n", b);

    return 0;
}
```

### Example Output

```
a = 20
b = 4
```

### Explanation

In:

```
a = (10, 20);
```

`10` is evaluated first, followed by `20`. The value of the entire expression is the value of the rightmost expression, so `a` receives `20`.

Similarly:

```
b = (1, 2, 3, 4);
```

evaluates the expressions from left to right, and the complete expression produces `4`.

The comma operator is different from commas used to separate function arguments or variable declarations. It specifically forms a single expression whose value is determined by its rightmost operand.
