C Program to Find the Sum of Cos Series

This C program is to find the sum of cos series given x and n
[cc lang=”c”]
#include
main()
{
int i,n,x;
float t,s;
printf(“enter the value of x,n n”);
scanf(“%d%d”,&x,&n);
t=1;
s=1;
for(i=1;i<=n;i++) { t=(-1)*((x*x)*t*i)/((2*i)*((2*i-1)*i)); s=s+t; printf("s=%6.2f & t=%6.2fn",s,t); } printf("n sum of the cos series=%5.2fn",s); } [/cc]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *