Advertisement
weldisalves

Lista 03 - exercício 20

Jun 13th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /* 20. Determine a quantidade de homens e mulheres (separadamente)
  4. que são maiores de idade, baseado numa lista de 200 pessoas.
  5. Considere apenas como entrada a informação se é
  6. homem ou mulher ('m' ou 'f') e a idade. */
  7.  
  8. int main()
  9. {
  10.     int idade,maiorHomem=0,maiorMulher=0,i;
  11.     char sexo;
  12.  
  13.     for(i=0;i<6;i++)
  14.     {
  15.         fflush(stdin);
  16.         printf("\n Digite o sexo da pessoa, homem ou mulher ('m' ou 'f'): ");
  17.         scanf("%c",&sexo);
  18.  
  19.         fflush(stdin);
  20.         printf("\n Digite a idade da pessoa:");
  21.         scanf("%d",&idade);
  22.  
  23.         if(idade >= 18)
  24.         {
  25.             if(sexo == 'm')
  26.             {
  27.                 maiorHomem++;
  28.             }else{
  29.                 maiorMulher++;
  30.                 }
  31.         }
  32.     }
  33.  
  34.     printf("\n Maiores de idade:\n");
  35.     printf("\n Homens: %d",maiorHomem);
  36.     printf("\n mulheres: %d",maiorMulher);
  37.  
  38.     getch();
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement