Advertisement
Gleeshoux

Domaci

Nov 27th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3. float a[50];
  4. float sr=0;
  5. int n;
  6. int i;
  7. int br0=0;
  8. printf("Unesite broj elemenata");
  9. scanf("%d",&n);
  10. printf("\nUnesite niz ");
  11. for(i=0;i<n;i++){
  12.     scanf("%f",&a[i]);
  13. }
  14. for(i=0;i<n;i++){
  15.     sr=sr+a[i];
  16.  
  17. }
  18. for(i=0;i<n;i++){
  19. if(a[i]==0)
  20.     br0++;
  21.  
  22. }
  23. sr=sr/n;
  24. printf("srednja vrednost je %.2f",sr);
  25. printf("\nBroj nula je %d",br0);
  26.  
  27. printf("\nNiz: ");
  28. for(i=0;i<n;i++){
  29.  printf("%.2f ",a[i]);
  30. }
  31. return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement