Make Your Search Easy ! :) Use me

Wednesday, August 9, 2017

Triangle related problem

Program to accept 3 angles and check if is it of a triangle. If yes, also find type of the triangle.


#include<iostream.h>
#include<conio.h>


void main()
 {
        int flag1,flag2,flag3;
              flag1=flag2=flag3=0;
              float angle1,angle2, angle3;
              cout<<"Enter 1st Angle : ";
              cin>>angle1;
              cout<<"Enter 2nd Angle : ";
              cin>>angle2;
              cout<<"Enter 2nd Angle : ";
              cin>>angle3;
              if(angle1+angle2+angle3==180)
              {
                if(angle1==angle2&&angle2==angle3)
                  { cout<<"\n\nGiven angles are of equilateral triangle."; }
                  if(angle1==angle2||angle2==angle3||angle1==angle3)
                     { flag1=1; }
                  if(angle1!=angle2 && angle1!=angle3)
                     { flag2=1; }
                  if(angle1==90||angle2==90||angle3==90)
                  {  flag3=1;}
              if(flag1==flag3)
            { cout<<"\n\nGiven angles are of a right angle isosceles triangle."; }
            if(flag2==flag3)
                  { cout<<"\n\nGiven angles are of a right angle scalene triangle."; }
               }
              else
              { cout<<"\n\nGiven angles are not of a triangle."; }
              getch();

 }

No comments:

Post a Comment