nikolas_serafini

Prova 2 - Questão 2

Jul 10th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     float angle,num = 1, fat = 2, coss = 1;
  6.     int i,j = 2, k = 3, sinal = 1,terms;
  7.  
  8.     printf("Entre com o angulo :\n");
  9.     scanf("%f",&angle);
  10.     printf("Entre com a quantidade de termos da serie :\n");
  11.     scanf("%d",&terms);
  12.    
  13.     for (i = 1; i <= terms; i++) {
  14.         sinal = (-1)*sinal;
  15.         num = num*angle*angle;
  16.         coss = coss + (sinal*num)/fat;
  17.         fat = fat*(i+j)*(i+k);
  18.     j++;
  19.         k++;
  20.     }
  21.  
  22.     printf("O cosseno eh : %f\n",coss);
  23.            
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment