Monday 30 January 2012

C code for tan x without using math.h....yes believe it.....


#include<stdio.h>
#include<conio.h>
void main()
{
float x,tanx,p=3.1412,a,b,c,d,e,f,g,n;
clrscr();
        printf("ENTER THE VALUE OF x\n");

      scanf("%f",&n);
x=(n*p)/180;
a=x*x*x;
b=a*x*x;


c=b*x*x;
d=c*x*x;
e=d*x*x;
f=e*x*x;
g=f*x*x;
if(x<3.1412/2)
{
tanx=x+(a/3)+((2*b)/15)+((17*c)/315)+((62*d)/2835)+(0.02*e)+(0.013*f)+(0.01*g);
printf("\ntan(%f)=%f",n,tanx);
}
else
printf("MATH ERROR\n");


getch();
}

No comments:

Post a Comment