#define _CRT_SECURE_NO_WARNINGS
#include<math.h>
#include<stdio.h>
double factorial(int);
#define PI 3.141592653589793
int main()
{
double angle, radian, sine, n, 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;
}
Last edited on
can't seem to get this to work
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!