Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <limits.h>
- int main()
- {
- int i,quant,age,bigage = 0,smallage = INT_MAX,counter = 0, sum = 0, people = 0;
- float med;
- printf("Entre com a quantidade de pessoas :\n");
- scanf("%d",&quant);
- for (i = 0; i < quant; i++)
- {
- printf("Entre com a idade do individuo :\n");
- scanf("%d",&age);
- if (age>bigage)
- {
- bigage = age;
- }
- if (age<smallage)
- {
- smallage = age;
- }
- if (age>18)
- {
- counter++;
- }
- sum = sum + age;
- people++;
- }
- med = (float)sum/(float)people;
- printf("Media das idades : %f\nMaior idade : %d\nMenor idade : %d\nPessoas maiores de idade : %d\n",med,bigage,smallage,counter);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment