1. ## C++ Pythag Calculator

Code:
```#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
int A, B, C, A1, B1, C1, A2, B2, C2, A3, B3, C3, A4, B4, C4 ;

cout << "Welcome to Maths Cheat. A program developed by Kej. \nI hope it helps! \n";
cout << "Pythag mode has been initialized. \nInput the variables in the form of A B C, with either B or C as 0 dependent\n on whether the hypotenuse is known. \n";
cout << "Now enter your variables in the form A B C Then press enter.";
cin >> A >> B >> C;
cout << "A = " << A <<"\n";
cout << "B = " << B <<"\n";
cout << "C = " << C <<"\n";

if (C == 0){
C1 = pow (A,2);
C2 = pow (B,2);
C3 = C1 + C2;
C4 = sqrt (C3);
cout << "Calculation in progess \nC = " << C4;

}

}```
Run this program why does C4 = 4 if you input 2 4 0, and not 5 as it should be?

Only just learning about math functions.

2. The answer for 2 4 0 should be ~4.47, but since you (implicitly) cast that result to int, the value is truncated and 4 remains.

In this particular case, 4 happens to be closer to the real value.

The worrying thing is that you are using integers to store the results of calculations that result in real numbers.

3. I see. So how can I get the program to output it to 2 decimal places?

BTW it did orignally execute under one variable, I changed it to break the calculation down stage by stage In an attempt to debug it.

4. There is no such thing as an int with 2 decimal places. A data type of int is inappropriate for this problem.

As far as your other printing problem goes, you should examine "setprecision".

5. Code:
```#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
long double A, B, C, X, Y, Z;

cout << "Welcome to Maths Cheat. A program developed by Kej. \nI hope it helps! \n";
cout << "Pythag mode has been initialized. \nInput the variables in the form of A B C, with either B or C as 0 dependent\n on whether the hypotenuse is known. \n";
cout << "Now enter your variables in the form A B C Then press enter.";
cin >> A >> B >> C;
cout << "A = " << A <<"\n";
cout << "B = " << B <<"\n";
cout << "C = " << C <<"\n";

if (C == 0){
Z = pow (10 ^ 2) + pow (10 ^ 2)
sqrt (Z)
cout << "Calculation in progess \nC = " << Z;

}

}```
That's the new code, now getting this error message. Can someone explain floating point numbers to me, or give me some tutorial links?

Code:
`_CRTIMP	double __cdecl pow (double, double);`

6. So how many arguments are you passing to pow? (Also, ^ means xor.)

This code makes even less sense. I'd also like to point out, that a rather straightforward way to square a value is x * x.

7. Originally Posted by anon
So how many arguments are you passing to pow? (Also, ^ means xor.)

This code makes even less sense. I'd also like to point out, that a rather straightforward way to square a value is x * x.
as in
Code:
`Result = sqrt((VectorX * VectorX) + (VectorY * VectorY));`

8. Originally Posted by abachler
as in
Code:
`Result = sqrt((VectorX * VectorX) + (VectorY * VectorY));`
This is why I hate coding sometimes, I make it more complicated than it is, thanks for both of you for the help.

Problem solved, it works.

9. Code:
```            else {
cout << "Trig mode has been initialized. Do you need to find an angle : yes (1), No (2). Enter you selection now!\n";

cout << "You choose to find a missing angle.";

}
else {
cout << "You choose to find a missing side.\n";
cout << "Enter your variables in the form of Adj, Opp, Hyp, Angle.\nLeaving variables blank as appropriate.";
cin >> Adj >> Opp >> Hyp >> Angle;
cout << "Opp = " << Opp <<"\n";
cout << "Hyp = " << Hyp <<"\n";
cout << "Angle = " << Angle <<"\n";

if (Hyp = 0){
cout << "test";
}

}
}```
Pythag section now works, I'm now developing the trig section, run into a block, this part of the program runs as far as displaying what the user entered for each variable it fails to print test at the end, any ideas.

10. Note that Hyp = 0 is always 0, hence always false, hence the true part of the if will never execute. (Now Hyp == 0 could be true and could be false.)

11. Slaps head against table, why didn't I see that.

EDIT

sorry for all these noobish questions.

Code:
```                            else {
cout << "You choose to find a missing side.\n";
cout << "Enter your variables in the form of Adj, Opp, Hyp, Angle.\nLeaving variables blank as appropriate.";
cin >> Adj >> Opp >> Hyp >> Angle;
cout << "Opp = " << Opp <<"\n";
cout << "Hyp = " << Hyp <<"\n";
cout << "Angle = " << Angle <<"\n";

if (Hyp == 0){
Hyp1 = sin(35);
cout << "test" << Hyp1;
}

}```
Why does sin 35 print as a completely wrong value?

My calculator outputs it as 0.5735764364, but the program outputs -0.428183. Noting my calculator is programmed to Math10

12. The C++ trigonometric functions work in radians rather than degrees.