nikolas_serafini

Lista 3 - Exercício 14

Jun 11th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <limits.h>
  3.  
  4. int main()
  5. {
  6.     int i,quant,age,bigage = 0,smallage = INT_MAX,counter = 0, sum = 0, people = 0;
  7.     float med;
  8.  
  9.     printf("Entre com a quantidade de pessoas :\n");
  10.     scanf("%d",&quant);
  11.     for (i = 0; i < quant; i++)
  12.     {
  13.         printf("Entre com a idade do individuo :\n");
  14.         scanf("%d",&age);
  15.  
  16.         if (age>bigage)
  17.         {
  18.             bigage = age;
  19.         }
  20.         if (age<smallage)
  21.         {
  22.             smallage = age;
  23.         }
  24.         if (age>18)
  25.         {
  26.             counter++;
  27.         }
  28.         sum = sum + age;
  29.         people++;
  30.     }
  31.  
  32.     med = (float)sum/(float)people;
  33.  
  34.     printf("Media das idades : %f\nMaior idade : %d\nMenor idade : %d\nPessoas maiores de idade : %d\n",med,bigage,smallage,counter);
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment