# quick question regarding the '==' sign.

This is a discussion on quick question regarding the '==' sign. within the C++ Programming forums, part of the General Programming Boards category; can you have a situation like Code: int a = 3; int b = 3; int c = 3; if ...

1. ## quick question regarding the '==' sign.

can you have a situation like

Code:
```int a = 3;
int b = 3;
int c = 3;

if (a == b == c){
cout<< "yes";
}```
or does it have to be

Code:
```if (a == b && a == c){
cout<< "yes";
}```

2. It can be the former (but you may get a result which you did not expect), but it should be the latter.

3. The second one will do what you want. The first one does:
Code:
`a == (b == c)`
Which can be re-written as:
Code:
```temp = (b == c);  // Makes a value of 0 or 1. (parenthesis not strictly necessary)
a == temp;```
--
Mats

4. So, to clarify (for myself),
Code:
`a==b==c ;`
results in false, even through a==b is true and b==c is true. Correct?

Todd

5. results in false, even through a==b is true and b==c is true. Correct?
Correct, except for special cases, e.g., a = b = c = 1.