Write a program to calculate the sum of cosine series
Write a program to calculate the sum of cosine series
Programmed by : kiran shrestha
roll no. : 10121
Programmed on : 6th feb,2011*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ()
{
int i,j,n;
float sum=0,fact=1,x;
printf (“enter terms = “);
scanf (“%d”,&n);
printf (“enter the angle of x = “);
scanf (“%f”,&x);
x =(x*22)/(7*180);
for (i=1;i<=n;i++)
{
for (j=1;j<=2*i-2;j++)
{
fact *=i;
sum += pow(x,(2*i-2))*pow(-1,(i+1))/fact;
}
}
printf (“sum =%f”,sum);
getch ();
}
Comments (2)