C Language
C Programs
/* Write a C program to find the sum of cos(x) series */
#include void main() printf(“Enter the number of the terms in aseriesn”); printf(“Enter the value of x(in degrees)n”); x1=x; x=x*(3.142/180.0); /* Degrees to radians*/ cosx=1; sign=-1; for(i=2;i<=n;i=i+2) for(j=1;j<=i;j++) cosx=cosx+(pow(x,i)/fact)*sign; printf(“Sum of the cosine series = %7.2fn”,cosx); } /*End of main() */ /*——————————————————–
#include
{
int n,x1,i,j;
float x,sign,cosx,fact;
scanf(“%d”,&n);
scanf(“%f”,&x);
{
fact=1;
{
fact=fact*j;
}
sign=sign*(-1);
}
printf(“The value of cos(%d) using library function = %fn”,x1,cos(x));
Output
Enter the number of the terms in aseries
5
Enter the value of x(in degrees)
60
Sum of the cosine series = 0.50
The value of cos(60) using library function = 0.499882
——————————————————–*/
More From sriramraj
sriramraj Recommends
Related posts:

