D
deanfamily11
Now, I've made a program that when the user enters 3 numbers, it is supposed
to tell the user if it is a right triangle by using the quadratic equation
(a^2 + b^2 = c^2). Now, granted it can be difficult to come up with 3
numbers on the fly that when run through that equation come out true, but
even with using 0's, it should be correct. If there is something wrong with
the following code, I'd appreciate the help, otherwise, tell me some numbers
that will work.
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
//declare variables
int side1, side2, side3;
double sum;
//get sides from the user
cout << "Enter 3 integers representing sides of a triangle: ";
cin >> side1 >> side2 >> side3;
//determine if it is a right triangle
sum = (side1 ^ 2) + (side2 ^ 2);
side3 = (side3 ^ 2);
if (sum == side3)
cout << "This is a right triangle.";
else
cout << "This is not a right triangle.";
return 0;
}
to tell the user if it is a right triangle by using the quadratic equation
(a^2 + b^2 = c^2). Now, granted it can be difficult to come up with 3
numbers on the fly that when run through that equation come out true, but
even with using 0's, it should be correct. If there is something wrong with
the following code, I'd appreciate the help, otherwise, tell me some numbers
that will work.
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
//declare variables
int side1, side2, side3;
double sum;
//get sides from the user
cout << "Enter 3 integers representing sides of a triangle: ";
cin >> side1 >> side2 >> side3;
//determine if it is a right triangle
sum = (side1 ^ 2) + (side2 ^ 2);
side3 = (side3 ^ 2);
if (sum == side3)
cout << "This is a right triangle.";
else
cout << "This is not a right triangle.";
return 0;
}