# How expression a = b == c (Multiple Comparison) evaluates in C programming?

Is a = b == c possible to write in c? – also in this Example learn to a==b==c (Multiple Comparison) evaluates in C programming.

## Is a = b == c possible to write in c language?

Contents

Expression ‘A = B == C’ is calculated as ‘A = (B == C)’. Consider inspecting the expression.

• Assignment operator (=) : It is used to assign the value to the left side variable.
• Equal to operator (==) : It is used to compare two variables.

Since Main C programming language does not support chaining comparison like x==y==z; each equal to operator (==) operates on two operands only. Then how expression x==y==z evaluates?

According to some operators associativity equal to operator (==) operates from left to right, that means associativity of equal operator (==) is left to right.

Expression x==y==z is actually (x==y) ==z, see how expression (x==y) ==z evaluates?

• (x==y) will be compared first as well as return either 1 (true) or 0 (false).
• Then value of variable z will be compared with the result of (x==y).

Consider the following example

```#include
int main(){
int x,y,z;
x=y=z=100;

if(x==y==z)
printf("Great...\n");
else
printf("Sorry...\n");

return 0;
}

```

Result

```Sorry...
```

### How result is “Sorry…”?

See the example, the values of x, y and z is 100 as well as you are thinking how condition is false here & why result is “False…”?

The expression is x==y==z which will evaluates like (x==y)==z now what will be the result?

• The result of (x==y) is 1 (i.e. true).
• And (1)==z will be 0 (i.e. false) because the value of z is 100 and 100 is equal not to 1.

### What does int i=(x,b,z) mean ?

```==> x,y will return y
==> y,z will return z
==> means (x,y,z) will return z
==> and Last Assign z to variable i which will be actual result.
```

I hope you get an idea about a = b == c.
I would like to have feedback on my infinityknow.com.