Say you have variables A B C, that the user puts in a side of a triangle. Obviously I am attempting to make a program that checks to see if a2+b2=c2 is true. The question is, how do I raise the variable to the second power?
Im using Dev C++
#include<iostream>
#include<math.h>
#include <stdlib.h>
usingnamespace std;
void Start;
void GetResults();
char a, b, c;
void
Start()
{
while((a * a) + (b * b) != (c * c))
{
cout << "Please put in line A\n";
a = 0;
cin >> a;
cout << "please put in line B\n";
b = 0;
cin >> b;
cout << "please put in line C\n";
c = 0;
cin << c;
if((a * a) + (b * b) != (c * c))
{
cout << "This is not a Right Triangle.\n";
}
}
GetResults();
if((a * a) + (b * b) == (c * c))
{
cout << "This is a Right Triangle.\n";
}
}
void
GetResults();
{
}
int
main();
{
a = 0;
b = 0;
c = 0;
cout << "Finds Right Triangles!!!!!\n";
Start();
return 0;
}
This what i have so far but it wont compile, it comes with this message Circular main <-Main.o dependency dropped...
I dont even know if this would be remotely the right way to write this program
You need to make sure that variable c is the hypotenuse of the right triangle. (That's the longest side of the triangle.) To do this, make a variable called temp of the same type as a, b, and c. Then after you input a, b, and c, use code like this:
1 2 3 4 5 6 7 8 9 10
if (a > c) {
temp = a;
a = c;
c = temp;
}
if (b > c) {
temp = b;
b = c;
c = temp;
}
Also, you should use a do-while loop with this code, not a while loop.