Write a program to find weather they are the three sides of a triangle or not? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Write a program to find weather they are the three sides of a triangle or not?

a,b and c are the three given sides. now find out they are the sides of a triangle or not.

29th Aug 2017, 10:47 AM
Sahil Luthra
Sahil Luthra - avatar
7 Answers
+ 3
no yr you guys getting me wrong lemme explain for eg 3, 4 and 5 are the given sides. now check wether they can be a side of a triangle or not?( sum of two sides of a triangle always greater thn its third side)
29th Aug 2017, 11:12 AM
Sahil Luthra
Sahil Luthra - avatar
29th Aug 2017, 11:44 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 3
nyc logic @chirag
29th Aug 2017, 3:44 PM
Sahil Luthra
Sahil Luthra - avatar
+ 2
//somthing like this? Scanner scn = new Scanner(System.in); String a,b,c,x; x = scn.nextLine(); if(x.equals("a") || x.equals("b") ||x.equals("c")) { System.out.println(x + " is a side of a triangle"); } else { System.out.println(x + " is not a side of a triangle"); }
29th Aug 2017, 11:06 AM
D_Stark
D_Stark - avatar
+ 2
depends on third side for eg 4 4 9 these can't be sides of a triangle.
29th Aug 2017, 11:20 AM
Sahil Luthra
Sahil Luthra - avatar
+ 1
hum, what are a,b and C ? 2D points, 3D points ? Arrays of either of those ?
29th Aug 2017, 10:51 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
why?
29th Aug 2017, 11:23 AM
D_Stark
D_Stark - avatar