Advertisement
stev4

Untitled

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