I know their is a sin function in math.h but I want to make that function at my own, just for fun. I have created sin function based on Macluarin expansion of the sine function.
I write power function and factorial function, they work correctly from int main,but they do not work in sin function, here is my code
printf("\n\nPlease enter a value to find corresponding sin value\n");
printf("\nYour value is\n %f",y);
double sin(int z)
int factorial(int x)
sum = sum*i;
int power(int x,int y)
unsigned long long int i,sum=1;
The formula expects values in radians but you're using integers so I'm assuming you give it degrees. That will make the formula give wrong values.
Also you use
ints as return values from
power() which will cause overflows. If you have 32bit machine even giving 2 to your formula will overflow since
int can only go up to 2^31-1 and your trying to get 2^33.
Also if your compiler doesn't complain that you're returning an
unsigned long long int from a function that has
int as a return type please increase the warning level.