Okay so this is for homework and i am stuck, we have to write our own cos func. I understand how to set every thing up and i have the formula that

cos(x)=(-1^n)*((x^2n)/(2n)!)

this is what i have set up so far. any help would be great.

Code:

`#define _CRT_SECURE_NO_WARNINGS`

#include <stdio.h>

#include <math.h>

float cosd(float);

void main() // shell to test the cosd() function

{ // This program is a poor example of programming.

// It is only for testing another function, in

// this case the cosd() function.

float angle, answer;

do

{

printf("Enter angle (in degrees): ");

scanf("%f",&angle);

answer=cosd(angle);

printf("cos(%2f)=%6.4f\n\n",angle,answer);

} while (angle != -99.0); // -99 is sentinel value

}

// cosd() function goes here

float cosd(float d)

{

float r,term,sum,result; <--- result is not being used

r=(d)*(3.14159265/180);

term=1;

while(**term > 0.0005**)

{

sum=((r*r)/((term*2)*(2*term-1)))*(term-1);

}

return sum;

}