#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;
}
This code reads three integers and checks if they can form a triangle by verifying the triangle inequality theorem (sum of any two sides must be greater than the third). It prints YES if valid, NO otherwise.
- The code does not handle cases where the input values could be zero or negative. Triangle sides must be positive numbers, so consider adding a check for that.
- The condition uses integer arithmetic, which is fine for whole numbers, but if the problem expects floating-point inputs, the variables and scanf format specifier should be changed accordingly.