Guest User

Untitled

a guest
Oct 16th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. int i,n,x,somma;
  6. float media;
  7.  
  8. printf(" - CALCOLO DELLA MEDIA - \n");
  9. printf("Inserisci un numero intero positivo:\n");
  10. do {
  11. printf("==> ");
  12. scanf("%d",&n);
  13. } while(n < 0);
  14.  
  15. printf("Inserisci %d numeri:\n", n);
  16. for (i=1; i <= n; i++) {
  17. printf("%d numero ==> ", i);
  18. scanf("%d",&x);
  19. somma+=x;
  20. }
  21.  
  22. media=(float)somma/n;
  23.  
  24. printf("La media e': %.2f\n",media);
  25.  
  26. system("pause");
  27. return(0);
  28. }
Add Comment
Please, Sign In to add comment