Advertisement
NoxScourge

Untitled

Sep 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include "stdio.h"
  2.  
  3.  
  4. void main() {
  5.  
  6. float srednjavrednost;
  7. float broj;
  8. int suma = 0;
  9. float i = 0;
  10. float prosecnavrednost = 0;
  11.  
  12. printf("Unesite srednju vrednost");
  13.  
  14. scanf("%f", &srednjavrednost);
  15.  
  16.  
  17. FILE *f = fopen("C:\\Users\\Nox Scourge\\Desktop\\zadatak.txt", "r");
  18.  
  19. while (prosecnavrednost < srednjavrednost) { //nema !feof jer ne moee da se izvede tako
  20.  
  21. fscanf(f, "%f", &broj);
  22.  
  23. i++;
  24.  
  25. suma += broj;
  26. prosecnavrednost = suma / i;
  27.  
  28. if (prosecnavrednost > srednjavrednost) {
  29.  
  30. printf("Presli ste pocetnu vrednost =%f , vrednost je =%f \n", srednjavrednost, prosecnavrednost);
  31. }
  32. }
  33.  
  34. fclose(f);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement