#include <stdio.h>
int main() {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if (a+b>c,a+c>b,b+c>a){
printf("YES\n");
}
else {
printf("NO\n");
}
return 0;
}
The code reads three integers and attempts to check if they can form a triangle by verifying the triangle inequality (sum of any two sides greater than the third). However, the condition in the if statement is written incorrectly.
- The comma operator in `a+b>c, a+c>b, b+c>a` does not combine the conditions as intended. In C, the comma operator evaluates each expression but only the last one determines the result. So only `b+c>a` is actually checked.
- To combine multiple conditions, you need to use the logical AND operator `&&` between them.