win32 native console application

i want ot insert trignomatric function in my calculator ..how to use trignomatric ratioes and get correct answar in c++ native win32 console application
plzz help me wd example
The basic trig functions are found in <cmath>. Remember that we work in radians rather than degrees.
how to exactly convert to radian?
Divide by (2*pi/360)
which value of pi i write?
What's your favourite value of pi?
when i insert 22/7 then it replies wrong .it says that cos 90 is equal to 1..thts wrong
Last edited on
22/7 radians is not 90 degrees.
Last edited on
i mean if i convrt degre to radian by putting value of pi as 22/7 then answars are wrong
One of these things is true:

1) The universe has changed and cos and sin have different answers now.
2) Your code is wrong.
3) Your code is giving you a correct answer but you don't understand what it's saying.

I'm going to guess 2, but it could be 3.
Last edited on
closed account (z05DSL3A)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main ()
{

    cout << setprecision(20) << cos(90.0 * 2 * 3.14159265358979 / 360.0) << endl;
    cout << setiosflags(ios::fixed) << setprecision(20)<< cos(90.0 * 2 * 3.14159265358979 / 360.0) << endl;

    return 0;
}
22/7 is a poor substitute for PI. It's only used when you're doing all your calculations by hand.

acos(-1.0) should give you a good value for PI. This is because there are 2PI radians in a full circle. So a semi-circle has PI radians. cos(PI) is -1, so arc cos(-1) is PI. It's not obvious without a diagram of a unit circle.
http://pubs.opengroup.org/onlinepubs/007908799/xsh/acos.html
Last edited on
Topic archived. No new replies allowed.