Tuesday 24 December 2013

If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is valid or not. The triangle is valid if the sum of two sides is greater than the largest of the three sides.

 #include<iostream>
 using namespace std;
#include<conio.h>
int main()
{
  float side1,side2,side3;

  cout<<"Enter three sides of triangle in ascending order:\n";
  cin>>side1>>side2>>side3;
  if(side1+side2>side3)
  cout<<"\nThe triangle is valid.";
  else
  cout<<"\nThe triangle is invalid.";
  getch();
return 0;
}

1 comment:

  1. http://ba-programmer.blogspot.in/2014/03/mini-project-snake-game-in-c.html

    ReplyDelete