-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsinloop.c
More file actions
36 lines (31 loc) · 1.02 KB
/
Copy pathsinloop.c
File metadata and controls
36 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*----------------------------------------------------------------------------------------------------------------------------------------------------------
sinloop.c
Program to calculate the sine of an angle in degrees by finding the sum of the series
sin(x)=x-((x*x*x)/3!)+((x*x*x*x*x)/5!)-((x*x*x*x*x*x*x)/7!)+............
where x=((22.0/7)*Theta)/180.0
DIVYA RAJ K
07-09-2018
-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
main()
{
int Theta,i=1;
float SinX,X,pi,Sum;
pi=22.0/7;
system("clear");
printf("Program to calculate the sine of a degree by finding the sum of the series sin(x)=x-((x*x*x)/3!)+((x*x*x*x*x)/5!)............\n\n");
printf("Enter the degree:\n");
scanf("%d",&Theta);
X=pi*Theta/180.0;
Sum=X;
SinX=X;
while(abs(Sum)>0.0001)
{
Sum=((-1)*Sum*pow(X,2))/((2*i+1)*(2*i));
SinX=SinX+Sum;
i++;
}
printf("\nThe sin(%d) = %f",Theta,SinX);
}