Advertisement
stev4

Untitled

Nov 1st, 2019
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(){
  5.  
  6. int i,n,j;
  7. double z;
  8. double suma=0;
  9. double cos;
  10. double fakt,gornji,donji,clan;
  11.  
  12. do{
  13.     printf("Molimo unesite vrednost za N-> ");
  14.     scanf("%d",&n);
  15. } while (n<=0);
  16. do{
  17.     printf("Molimo unesite vrednost za Z-> ");
  18.     scanf("%lf",&z);
  19. } while (z<-1 || z>1);
  20.  
  21. for(i=0; i<=n;i++){
  22. gornji=pow(-1,i)*pow(z,2*i);
  23. fakt=1.0;
  24. for(j=2; j<=(2*i);j++){
  25. fakt*=j;}
  26. clan=gornji/fakt;
  27.  
  28. suma+=clan;
  29.  
  30.  
  31.  
  32.  
  33. }
  34. printf("\n\t-----------------------------");
  35. printf("\n\t  cos(%lf)= %lf\n",z,suma);
  36. printf("\n\t-----------------------------\n");
  37.  
  38.  
  39.  
  40.  
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement