+ 1

Attention can anyone please make it error free!

int main() { int a; int b; int c; cin>>a>>b>>c; if (a+b<=c||a+c<=b||c+b<=a){ cout<<"Invalid triangle!\n"; } else { cout<<"Valid triangle!\n"; } if (a=b=c) { cout<<"Its an equilateral triangle\n"; } if (a=b||a=c||c=b&&!(a=b=c)) { cout<<"Its an escalateral triangle !\n"; } if (!(a=b||a=c||c=b)){ cout<<"Its a scalene triangle!\n"; } cout<<"Thanks for checking my code!"; return 0; }

25th Oct 2017, 1:08 PM
[No Name]
3 Respostas
+ 8
Okay, I didn't check your actual math for triangles, but I fixed a lot of the issues you were having. At first glance, there is some other logic you'll want to handle to properly do this as well. Your main issue was that you were using assignment operators (=) instead of comparison operator (==). Hope that helps. https://code.sololearn.com/cR5mEtssZVw8/#cpp int main() { int a; int b; int c; cin>>a>>b>>c; if (a+b<=c||a+c<=b||c+b<=a){ cout<<"Invalid triangle!\n"; } else { cout<<"Valid triangle!\n"; } if (a==b==c) { cout<<"Its an equilateral triangle\n"; } else if (a==b||a==c||c==b&&!(a==b==c)) { cout<<"Its an escalateral triangle !\n"; } else if (!(a==b||a==c||c==b)){ cout<<"Its a scalene triangle!\n"; } cout<<"Thanks for checking my code!"; return 0; }
25th Oct 2017, 1:15 PM
AgentSmith
+ 4
@Gordie Yup. As I said in my post, I didn't check his math and I informed him that his logic is off. I merely got rid of his syntax errors so it'll run, and left the logic errors to him. Netkos Ent: "I didn't check your actual math for triangles, but I fixed a lot of the issues you were having. At first glance, there is some other logic you'll want to handle to properly do this as well." However, it's worth noting that you're right and it'll check it as a true/false value first.
25th Oct 2017, 2:12 PM
AgentSmith