Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.c
- * Author: alumno
- *
- * Created on 31 de octubre de 2014, 12:39
- */
- #include <stdio.h>
- #include <stdlib.h>
- /*
- *
- */
- int N,i,a,s;
- double x,ans;
- double potencia(double x,int N){
- double x1;
- i=1;
- x1=x;
- while(i<N){
- x1=x*x1;
- i++;
- ans=x1;
- }
- return(ans);
- }
- long factorial(int N){
- a=N;
- i=a-1;
- while(i>0){
- a=a*i;
- i--;
- }
- return(a);
- }
- int main(int argc, char** argv) {
- double resultado,termino,suma,terminoabs;
- printf("Introduce el ángulo en radianes:");
- scanf("%lf",&x);
- N=2;
- s=1;
- termino=1;
- while(termino>0.0005){
- termino=(potencia(x,N))/(factorial(N));
- resultado=resultado+termino*s;
- N=N+2;
- s=s*(-1);
- }
- resultado=1-resultado;
- printf("La solucion es: %lf",resultado);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement