Search This Blog

Saturday, February 19, 2011

c program for cos series..............


C  Programm for cos series……………
 //COS SERIES 
#include<stdio.h>
 
#include<conio.h>
 
#include<math.h>
 
main()
 
{
 
int i,n,x;
 
float t,s;
 
clrscr();
 
printf("enter the value of k,n \n");
 
scanf("d",&x,&n);
 
t=1;
 
s=1;
 
for(i=1;i<=n-1;i++)
 
{
 
t=(-1)*((pow(x,2)*t*i))/((2*i)*((2*i-1)*i));
 
s=s+t;
 
printf("s=%6.2f & t=%6.2f\n",s,t);
 
}
 
printf("\n sum of the cos series=%5.2f\n",s);
 
return(0);
 
}



No comments:

Post a Comment