SINE SERIES USING C




To write a c program to find the summation of the sine series.

/*SINE SERIES*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,t,f,n,j;
float x,s=0;
clrscr();
printf("\n\t**SINE SERIES**\n\t");
printf("\nEnter the value for n:");
scanf("%d",&n);
printf("\nEnter the value of x in degrees:");
scanf("%f",&x);
x=x*3.14/180;
t=1;
for(i=1;i<=n;i=i+2)
{
f=1;
for(j=1;j<=i;j++)
{
f=f*j;
}
s=s+pow(x,i)/f*t;
t=t*-1;
}
printf("\n\nThe calculated value is=%f",s);
printf("\n\nThe built-in value is=%f",sin(x));
getch();
}



OUTPUT:      

        **SINE SERIES**

Enter the value for n: 5
Enter the value of x in degrees: 45

The calculated value is=0.706861
The built-in value is=0.706825


Comments

Popular posts from this blog

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE

BOOKS DETAILS USING C STRUCTURE

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE