/*
* File: main.c
* Author: student
*
* Created on February 22, 2011, 8:56 AM
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*
*
*/
int main(double argc, char** argv) {
double num1;
printf("Enter a positive integer: ");
scanf("%lf",&num1);
double val = num1;
double sin = val - (pow(val, 3)/(3*2)) + (pow(val,5)/(5*4*3*2)) - (pow(val,7)/(7*6*5*4*3*2)) + (pow(val,9)/(9*8*7*6*5*4*3*2));
double cos = 1 - (pow(val,2 )/(2)) + (pow(val,2 )/(4*3*2)) - (pow(val,6 )/(6*5*4*3*2)) + (pow(val,8 )/(8*7*6*5*4*3*2));
printf("sin(x) = %lf\n", sin);
printf("cos(x) = %lf\n", cos);
return (EXIT_SUCCESS);
}
No comments:
Post a Comment