//Program to check a triangle is valid or not
#include<iostream>
using namespace std;
class triangle
{
//int a,b,c;
public:
int validation(int x, int y, int z)
{
if((x+y+z) == 180)
return(1);
else
return(0);
}
};
int main(void)
{
int a,b,c,v;
triangle t;
cout<<"Enter three angles of a triangle:\n";
cout<<"Angle a: ";
cin>>a;
cout<<"Angle b: ";
cin>>b;
cout<<"Angle c: ";
cin>>c;
cout<<endl;
v=t.validation(a,b,c);
{
if(v==1)
cout<<"Valid Triangle as the sum of three angles "<<a<<" + "<<b<<" + "<<c<<" = 180";
else
cout<<"Invalid triangle as the sum of three angles "<<a<<" + "<<b<<" + "<<c<<" = "<<(a+b+c);
}
}
No comments:
Post a Comment
Comments please: