help help help in for tomorrow???

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
37
38
39
40
41
42
#define _CRT_SECURE_NO_WARNINGS

#include<math.h>
#include<stdio.h>

double factorial(int);

#define PI 3.141592653589793

int main()
{
	int n;
	float angle, radian, sine,  x, factorial, s, i;
	x = 1;
	printf("Enter angle in degrees (0 to quit)\n");
	scanf("%f", &angle);

	for (i = 1; i <= 15; i++){
		factorial = factorial*n;

		return factorial;

		while (angle != 0){
			radian = angle*(PI / 180);
			sine = 0;
			n = 1;
			while (n <= 15)
			{
				s = (radian - (pow(radian, n)) / (factorial));
				n++;
			}

			printf("sin(%f)=%f\n", angle, s);

			printf("Enter angle in degrees (0 to quit): ");
			scanf("%f", &angle);

		}
	}

	return 0;
}
hi

i've been at this for days, it works finds the x value but it stagger the results in 5 showings
the code should find the sine value in 5 stages and then final answer

formula below

sin(x) = x −x3/3!+x5/5!−x7/7!+x9/9!
#define _CRT_SECURE_NO_WARNINGS

#include<math.h>
#include<stdio.h>

double factorial(int);

#define PI 3.141592653589793

int main()
{
int n;
float angle, radian, sine, x, factorial, s, i;
x = 1;
printf("Enter angle in degrees (0 to quit)\n");
scanf("%f", &angle);

for (i = 1; i <= 15; i++){




while (angle != 0){
radian = angle*(PI / 180);
sine = 0;
n = 1;
while (n <= 15)
x= radian; sine = 0; for (i = 1; i<15; i++) { sine += x; x*= -(radian*radian) / (2 * i) / (2 * i + 1); } printf("sine of %d is %f\n", angle, sine);;

}
}

return 0;
}
Topic archived. No new replies allowed.