Print Friendly and PDF
(Sides of a Triangle) Write a program that reads three nonzero double values and determines and prints whether they could represent the sides of a triangle. Solution:
(Sides of a Triangle) Write a program that reads three nonzero double values and determines and prints whether they could represent the sides of a triangle.

Solution:


#include < iostream>
using namespace std;
int main()
{
double a, b, c;
cout << "Enter the three numbers: " << endl;
cin >> a >> b >> c;
if( (a + b <= c) | | (b + c <= a) | | (a + c <= b) )
cout << "They could NOT represent the sides of a triangle" << endl;
else
cout << "They could represent the sides of a triangle" << endl;
//for pause
system("PAUSE") ;
return 0;
}

zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: