Print Friendly and PDF
(Sides of a Right Triangle) Write a program that reads three nonzero integers and determines and prints whether they’re the sides of a right triangle. Solution:
(Sides of a Right Triangle) Write a program that reads three nonzero integers and determines and prints whether they’re the sides of a right triangle.

Solution:

#include < iostream>
using namespace std;
int main()
{
int a, b, c;
cout << "Enter three numbers: " << endl;
cin >> a >> b >> c;
if( (a*a + b*b == c*c) | | ( b*b + c*c == a*a ) | | ( c*c + a*a == b*b ) )
cout << "they are the sides of a right triangle" << endl;
else
cout << "they are NOT the sides of a right 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: