ramontricolor12

LISTA 03 - Exercício 14

Jun 15th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 03 - Exercicio 14.c
  3.    Objetivo: Informa alguns dados sobre as idades de alguns individuos.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. int main()
  9. {
  10.     int i, numeroPessoas, idade, totalIdades = 0, maior = 0, menor = -1, cont18 = 0, media;
  11.  
  12.     printf("\nInforme o numero de pessoas: ");
  13.     scanf("%d", &numeroPessoas);
  14.  
  15.     for(i = 1; i <= numeroPessoas; i++)
  16.     {
  17.         printf("\nDigite a idade do %d individuo: ", i);
  18.         scanf("%d", &idade);
  19.  
  20.         totalIdades += idade; //soma necessaria para calcular a media.
  21.         if(idade > maior)
  22.             maior = idade;
  23.         if(idade < menor || menor == -1)
  24.             menor = idade;
  25.         if(idade >= 18)
  26.             cont18++;
  27.     }
  28.     media = totalIdades / numeroPessoas;
  29.     printf("\n------INFORMACAO------\n");
  30.     printf("\nMEDIA DE IDADE:                   %d\n", media);
  31.     printf("\nMAIOR IDADE:                      %d\n", maior);
  32.     printf("\nMENOR IDADE:                      %d\n", menor);
  33.     printf("\nQUANT. PESSOAS MAIORES DE IDADE:  %d\n", cont18);
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment