I am making a calculator which shoul not use cmath.h. I was just thinking that how is it possible to calculate trigonometric functions without cmath.h. Please help me. Thanks in advance.

Use google. Find out how a trig function is calculated in the real world. Then once you find that, convert the equation into code.

You can try computing trigo values by this :

sin x = x - (x^3 / 3!) + (x^5 / 5!) – (x^7 / 7)! + ……………..

cos x = 1 - (x^2 / 2!) + (x^4 / 4!) – (x^6 / 6!) + ……………..

tan x = sin x / cos x

cosec x = 1 / sin x

sec x = 1 / cos x

cot x = 1 / tan x

I was going to suggest exactly what MrIdul posted above.

It may take some effort to write the loops for sine and cosine to the degree of precision you need, unless you have experience with the infinite series topic in advanced calculus.

Code for sine :

#include<iostream.h>
void main()
{
int i=2,n=1,s=1,x,a=1,d;
float r = 1, x1, sum;
cout<<"\n\n x : " ;
cin>>x;
x1 = 3.142 * (x / 180.0);
sum = x1;
while(i <= n) // a : alternating power
{
a = a + 2;
d = d * a * (a - 1);
sum = sum + (r / d) * s;
s = s * (-1);
r = r * x1 * x1;
i+= 2;
}
cout<<"\n sin(x) = "<<sum;
}

-------code ends--------

Similarily you can modify the code for others..

But how can I find arcsin etc. That is the real problem. I googled it a lot but could not find it any help would be appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.