COSINE SERIES USING C



To write a c program to find the summation of the cosine series.


/*COSINE SERIES*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,t,f,n,j;
float x,s=0;
clrscr();
printf("**COSINE SERIES**");
printf("\nEnter the value for n:");
scanf("%d",&n);
printf("\nEnter the value of x in degree:");
scanf("%f",&x);
x=x*3.14/180;
t=1;
for(i=2;i<=n;i=1+2)
{
f=1;
for(j=1;j<=i;j++)
{
f=f*j;
}
s=s+pow(x,i)/f*t;
t=t*-1;
}
printf("\n\nThe calculated value is:%f",s);
printf("\n\nThe built-in value is:%f",cos(x));
getch();
}
 

Comments

Popular posts from this blog

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE

BOOKS DETAILS USING C STRUCTURE

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE