Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

bunyonb

  • 3 years ago

2. Write a program which, given three values representing the sides of a triangle prints: * 0 if the values cannot be the sides of any triangle. This is so if any value is negative or zero, or if any length is greater than the sum of the other two. * 1 If the triangle is equilateral. * 2 If the triangle is isosceles * 3 if the triangle is scalene.

  • This Question is Closed
  1. bunyonb
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    HERE IS MY CODE SO FAR: /*Write a program which, given three values representing the sides of a triangle prints: * 0 if the values cannot be the sides of any triangle. This is so if any value is negative or zero, or if any length is greater than the sum of the other two. * 1 If the triangle is equilateral. * 2 If the triangle is isosceles * 3 if the triangle is scalene.*/ #include <iostream> #include <cmath> using namespace std; int main(){ double a,b,c; cout<<"enter 3 values of your triangle"<< endl; cin>>a>>b>>c; if( (a==b&& a!=c) || (a==c && a!=b) || (b==c && b!=a) ) { cout<< " This triangle is Isosceles"<<endl; } else if( a==b && a==c){ cout<< "This triangle is equilateral"<<endl; } else if (a!=b && a!=c){ cout<<" This triangle is scalene"<<endl; } return 0; }

  2. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy