Just looking quickly, there are a few things that you need to fix.
First, ALWAYS make sure your variables have no spaces in them. Otherwise, the compiler doesn't know when the variable stops and then next part of the expression starts. For example, instead of
side a
, try something like
side_a
or
sideA
.
Another thing is that with your conditional statements, only the first one will be executed conditionally. C/C++ don't care about line indents, so the fact that you have indented like that will only confuse people. Instead, put the insides inside curly braces, like this:
1 2 3 4 5 6 7 8 9
|
if ( /* conditinal statement here*/ ) {
// What to do
} else if ( /* conditional statement here */ ) {
// What to do otherwise
} else if ( /* conditional statement here */ ) {
// etc...
} else {
// What to do if all other statements return false
}
|
Also notice how the conditional statement is contained within paranthesis, rather than out in the open as you had them.
Finally, where you have
(side a)^2
, it will not do what you think. The ^ operator is NOT the "to the power of operator", it is actually the binary XOR operator. If you don't understand that, don't worry. All you need to know is that you should do this:
1 2 3 4
|
// sideA^2;
pow(sideA, 2);
// OR
sideA * sideA;
|