In this program user ask to compute Sine (trigonometric function) Series. The Variable of float or integer type declared that will be use to contain the value. User asks to enter the value and then the computation of PI function described. Here term variable used for temporary value container as in the program this variable contain the x1 and then swapped for Sine. For loop statement also been used for varying the condition. Then using compatible condition the output is displayed.
Problem Statement:
The trigonometric Symbol Sine Series to be computed through a C program.
- Declare Value of PI and ACC.
- Used Computation algorithm.
- Using Loop Statement.
- Display result On the Screen.
Here is source code of the C program to compute the Sine Series. The C program is successfully compiled. The program output is also shown below.
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define ACC 0.000001
#define PI 3.14
void main()
{
int x,i;
float x1,x2,sine=0,term;
clrscr();
printf("Enter the X value : ");
scanf("%d",&x);
x1=(x*PI)/180;
x2=x1*x1;
term=x1;
sine=term;
for(i=3;fabs(term)>ACC;i=i+2)
{
term = (x2*(-term))/(i*(i-1));
sine = sine+term;
}
printf("\n%f",sine);
getch();
}
Output :
Enter the X value : 100
0.984961