Java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter side a: ");
int a = sc.nextInt();
System.out.print("Enter side b: ");
int b = sc.nextInt();
System.out.print("Enter side c: ");
int c = sc.nextInt();
if (a + b > c && a + c > b && b + c > a) {
System.out.println("Triangle is Valid");
} else {
System.out.println("Triangle is Not Valid");
}
sc.close();
}
}Output
Enter side a: 3 Enter side b: 4 Enter side c: 5 Triangle is Valid
We use the triangle inequality theorem: sum of any two sides must be greater than the third side.