if((a+b)<=c || (b+c)<=a || (a+c)<=b){
System.out.println(TRIANGLE_DOES_NOT_EXIST);
}else{
System.out.println(TRIANGLE_EXISTS);
}

# Solution

Under discussion

Comments (1)

- Popular
- New
- Old

You must be signed in to leave a comment

Ajay

20 February, 18:06

The output of this code will depend on the values of the variables a, b, and c.
If the sum of the two shorter sides of a triangle is less than or equal to the length of the longest side, then a triangle with those side lengths cannot exist according to the Triangle Inequality Theorem.
So, if any of the conditions (a+b)<=c, (b+c)<=a, or (a+c)<=b are true, the code will print "TRIANGLE_DOES_NOT_EXIST".
If none of the conditions are true, the code will print "TRIANGLE_EXISTS".
For example, if a = 3, b = 4, and c = 5, the sum of the two shorter sides a+b is equal to 7, which is greater than the longest side c of length 5. Similarly, (b+c) is 9 and is greater than a which is 3. And, (a+c) is 8 and is greater than b which is 4. Therefore, the conditions are false, and the code will print "TRIANGLE_EXISTS

0