Tuesday 24 December 2013

Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees. (c++ code)

#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
  float angle1,angle2,angle3,sum;
 
 cout<<"Enter 3 angle of a the triangle : ";
  cin>>angle1>>angle2>>angle3;
  sum=angle1+angle2+angle3;
  if(sum==180)
  {
   cout<<"the Triangle is Valid.";
  }
  else
  {
   cout<<"the Triangle is invalid.";
  }
  getch();

/*  Letuswithc:

       this page is designed to help you learn C or C++.
  Understandable C and C++ programming tutorials, compiler reviews, source code, tips and tricks. 
         */
         return 0;
}

No comments:

Post a Comment