Advertisement
weldisalves

Lista 03 - exercício 17

Jun 13th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /* 17. Calcule a média aritmética de 500 valores fornecidos pelo usuário. */
  4.  
  5. int main()
  6. {
  7.     float media,soma=0,valor,i;
  8.  
  9.     for(i=0;i<500;i++)
  10.     {
  11.         printf("\n Digite um valor: ");
  12.         scanf("%f",&valor);
  13.         soma += valor;
  14.     }
  15.  
  16.     media = soma/i;
  17.  
  18.     printf("\n Media: %.2f",media);
  19.  
  20.     getch();
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement