0

I am trying to write a function that calculates the sine of a given angle. The code works fine if the angle in degrees is less than 100...once the angle becomes greater than 100..the result is a large value. I don't know what I am doing wrong. Can someone point out the mistake...thanks a ton.

```
/*Calculate sin x */
typedef unsigned char u8;
typedef double u32;
double pow(u32 , int );
int fact(int );
#define PI 3.1415926
#include<stdio.h>
int main()
{
/*Angle being converted to radians*/
u32 angle_in_radians = 45 * (PI/180);
double sum =0;
int n = 1,i=0;
for(i=0; i<=16; i++)
{
/*calculate sin(x)*/
sum += pow( -1, i ) * pow( angle_in_radians, n )/fact(n);
n+=2;
}
printf("\nSIN is %f\n", sum);
getchar();
return 0;
}
double pow(u32 angle_in_radians, int n)
{
int power = 0;
if(n == 0)
return 1;
else return angle_in_radians * pow(angle_in_radians, n-1);
return power;
}
int fact(int n)
{
if(n == 0)
return 1;
else return n * fact(n-1);
}
```