#include<stdio.h>
float my_pow(float x, float y);
float my_fac(float z);
double my_cos(float t);
int main(void){
float a;
printf("Enter degree for cosine : ");
scanf("%f",&a);
printf("%f",my_cos(a));
return 0;
}
float my_pow(float x, float y){
int counter;
double powe = 1;
for(counter = 1 ; counter <= y ; counter++ ){
powe *= x;
}
return powe;
}
float my_fac(float z){
int counter3;
double fin = 1;
for(counter3 = 1; counter3 <= z; counter3++ ){
fin *= counter3;
}
return fin;
}
double my_cos(float t){
int counter2;
int counter4;
double poorNum = 1;
for(counter4 = 4 ; counter4 <= 50; counter4 += 4){
poorNum += my_pow(t,counter4) / my_fac(counter4);
}
for(counter2 = 2 ; counter2 <= 50; counter2 += 4){
poorNum -= my_pow(t,counter2) / my_fac(counter2);
}
return poorNum;
}