1. ## amoeba

Code:
```#include <stdio.h>
int main()
{
int num1,num2,num3;
printf("Enter 3 intergers:");
scanf("%d", &num1);
scanf("%d", &num2);
scanf("%d", &num3);
if( num1 == num2 == num3 )
printf("Equal!!");
else
printf("Not Equal!!");
system("pause");
return 0;
}```
why can't i get the correct ans?

2. [QUOTE=amoeba532;987150]
Code:
```#include <stdio.h>
int main()
{
int num1,num2,num3;
printf("Enter 3 intergers:");
scanf("%d", &num1);
scanf("%d", &num2);
scanf("%d", &num3);
if( num1 == num2 == num3 )
printf("Equal!!");
else
printf("Not Equal!!");
system("pause");
return 0;
}```
the conditional statement is not correct. num1==num2==num3 is the same as: (num1==num2)==num3. (num1==num2) return 0 or 1 for true or false. Whatever (num1==num2) return will be compared with num3. So in effect, you're not comparing num1, num2 and num3 together. You should not group all conditional test together.

3. okk.thx nimitzhunter

4. Originally Posted by amoeba532
okk.thx nimitzhunter

Learn how to use "and," by reading this: http://www.cprogramming.com/tutorial/lesson2.html

Then learn how to rock "?:" and then learn how to scan for 3 ints without writing 3 lines.

Here you go, chew on this and see if you can learn more.

Code:
```#include <stdio.h>
int main(void){
int one, two, three;
printf("Enter 3 ints seperated by spaces:");
scanf("%d %d %d", &one, &two, &three);
((one == two) && (two == three)) ? printf("Equal\n") : printf("Not Equal\n");
return 0;
}```
Short, sweet and to the point.

edited: gave main a return value.

5. Originally Posted by tenchu
Learn how to use "and," by reading this: Cprogramming.com Tutorial: If Statements

Then learn how to rock "?:" and then learn how to scan for 3 ints without writing 3 lines.

Here you go, chew on this and see if you can learn more.

Code:
```#include <stdio.h>
void main(void){
int one, two, three;
printf("Enter 3 ints seperated by spaces:");
scanf("%d %d %d", &one, &two, &three);
((one == two) && (two == three)) ? printf("Equal\n") : printf("Not Equal\n");
}```
Short, sweet and to the point.
Some compiler may protest "void main()". Standard practice is "int main()"

6. True, but I was keeping the example short and sweet with a focus on the question/point about comparison operators. I edited the original in case it causes confusion.

7. If you really want to use the ternary operator, I suggest:
Code:
```#include <stdio.h>

int main(void) {
int one, two, three;
printf("Enter 3 ints seperated by spaces:");
scanf("%d %d %d", &one, &two, &three);
puts((one == two && two == three) ? "Equal" : "Not Equal");
return 0;
}```
But if you want to have two separate printf or puts statements, then I would consider the if and else branches to be clearer as using the ternary operator then looks like obfuscation to me.

8. That looks more clear, nice catch!