ramontricolor12

LISTA 03 - Exercício 13

Jun 15th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 03 - Exercicio 13.c
  3.    Objetivo: Calcula a media de varios numeros.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. int main()
  9. {
  10.     int num = 0, soma = 0, cont = 0, media;
  11.  
  12.     while(num >= 0)
  13.     {
  14.         printf("\nInforme um numero: ");
  15.         scanf("%f", &num);
  16.         if(num >= 0)
  17.         {
  18.             soma += num;
  19.             cont++;
  20.         }
  21.     }
  22.  
  23.     media = soma / cont;
  24.     printf("\nMedia = %f \n", media);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment