Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CABEÇALHO
- Arquivo: LISTA 03 - Exercicio 20.c
- Objetivo: Determine a quantidade de homem e mulheres que são maiores de idade.
- Autor(a): Ramon Borges
- */
- #include <stdio.h>
- #define quantPessoas 4
- int main()
- {
- int i, contHom = 0, contMul = 0, idade;
- char sexo;
- for(i = 1; i <= quantPessoas; i++)
- {
- printf("\nQual o sexo da %d pessoa: ", i);
- scanf(" %c", &sexo);
- switch(sexo)
- {
- case 'm':
- printf("\nInforme a idade do homem: ");
- scanf("%d", &idade);
- if(idade >= 18)
- contHom++;
- break;
- case 'f':
- printf("\nInforme a idade da mulher: ");
- scanf("%d", &idade);
- if(idade >= 18)
- contMul++;
- break;
- default:
- printf("\nDigite o sexo corretamente: s ou f\n");
- }
- }
- printf("\nQUANTIDADE DE HOMENS MAIORES DE 18 ANOS: %d\n", contHom);
- printf("\nQUANTIDADE DE MULHERES MAIORES DE 18 ANOS: %d\n", contMul);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment