0% found this document useful (0 votes)
4 views1 page

Program 4-1

Uploaded by

gokulrgowda7244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Program 4-1

Uploaded by

gokulrgowda7244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Program 4: Program to calculate Sin(x)/Cos(x) using Taylor series.

#include<stdio.h>
#include<math.h>
int main()
{
float angle,Rangle,NRangle,den,term,sval,cval;
printf("enter value for angle");
scanf("%f",&angle);
Rangle=(angle*3.142)/180;
printf("sin(%f)=%f\n",angle,sin(Rangle));
printf("cos(%f)=%f\n",angle,cos(Rangle));
printf("the sin(%f)/cos(%f)=%f\n",angle,angle,sin(Rangle)/cos(Rangle));
NRangle=Rangle;
sval=0.0;
den=1.0;
term=NRangle/den;
int n,i;
printf("enter number of terms:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sval=sval+term;
NRangle=-NRangle*Rangle*Rangle;
den=den*(2*i)*(2*i+1);
term=NRangle/den;
}
NRangle=1.0;
cval=0.0;
den=1.0;
term=NRangle/den;
for(i=1;i<=n;i++)
{
cval=cval+term;
NRangle=-NRangle*Rangle*Rangle;
den=den*(2*i)*(2*i-1);
term=NRangle/den;
}
printf("the sin value is sin(%f)=%f\n",angle,sval);
printf("the cos value is cos(%f)=%f\n",angle,cval);
printf("the sin(%f)/cos(%f)=%f\n",angle,angle,sval/cval);

return 0;
}

You might also like