ramontricolor12

LISTA 03 - Exercício 20

Jun 28th, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 03 - Exercicio 20.c
  3.    Objetivo: Determine a quantidade de homem e mulheres que são maiores de idade.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7.  #include <stdio.h>
  8.  #define quantPessoas 4
  9.  int main()
  10.  {
  11.      int i, contHom = 0, contMul = 0, idade;
  12.      char sexo;
  13.  
  14.      for(i = 1; i <= quantPessoas; i++)
  15.      {
  16.          printf("\nQual o sexo da %d pessoa: ", i);
  17.          scanf(" %c", &sexo);
  18.  
  19.          switch(sexo)
  20.          {
  21.              case 'm':
  22.              printf("\nInforme a idade do homem: ");
  23.              scanf("%d", &idade);
  24.  
  25.              if(idade >= 18)
  26.                 contHom++;
  27.              break;
  28.  
  29.              case 'f':
  30.              printf("\nInforme a idade da mulher: ");
  31.              scanf("%d", &idade);
  32.  
  33.              if(idade >= 18)
  34.                 contMul++;
  35.              break;
  36.  
  37.              default:
  38.              printf("\nDigite o sexo corretamente: s ou f\n");
  39.          }
  40.      }
  41.      printf("\nQUANTIDADE DE HOMENS MAIORES DE 18 ANOS: %d\n", contHom);
  42.      printf("\nQUANTIDADE DE MULHERES MAIORES DE 18 ANOS: %d\n", contMul);
  43.      return 0;
  44.  }
Advertisement
Add Comment
Please, Sign In to add comment