Advertisement
Guest User

DN4

a guest
Dec 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. //1/(1*3)+1/(2*5)+1/(3*7)+...+1/(m*(2*m+1))
  6. float vsota(int vrednost);
  7. int main() {
  8.     int m;
  9.     float rez;
  10.     printf("Unesite vrednost m: ");
  11.     scanf("%d",&m);
  12.     rez = vsota(m);
  13.     printf("Vrednost: %f\n",rez);
  14.     system("PAUSE");
  15.     return 0;
  16. }
  17. float vsota(int vrednost){
  18.     int i;
  19.     float resenje=0.0;
  20.     float suma;
  21.     for(i = 1;i<=vrednost;i++){
  22.         suma = 1.0/(i*(2.0*i+1.0));
  23.         resenje += suma;
  24.     }
  25.     return resenje;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement