void main()
Author: Sanif S S
Site: theeduzone.blogspot.com
Email: sanifss@gmail.com#include<stdio.h>
#include<conio.h>
{
clrscr();
float term,termc,sum=0,sumc=0,x,k=0,j=1;
int n,c,i;
printf("menu\n");
printf("1.sine series\n2.cosine series\n");
printf("enter your choice\n");
scanf("%d",&c);
printf("enter the angle in degree\n");
scanf("%f",&x);
printf("enter the number of terms\n");
scanf("%d",&n);
x=((x*3.14)/180);
switch(c)
{
case 1:
term=x;
for(i=1;i<=n;i++)
{
sum=sum+term;
j=j+2;
term=((term*(-1)*x*x)/(j*(j-1)));
}
printf("sum of the sine series=%f\n",sum);
break;
case 2:
termc=1;
for(i=1;i<=n;i++)
{
sumc=sumc+termc;
k=k+2;
termc=((termc*(-1)*x*x)/(k*(k-1)));
}
printf("sum of the cosine series=%f",sumc);
break;
default:
printf("invalid choice");
}
getch();
}
No comments:
Post a Comment