nikolas_serafini

Lista 3 - Exercício 20

Jun 11th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int i,age,malecounter = 0,femalecounter = 0;
  6.     char opt;
  7.  
  8.     for (i = 0; i < 5; ++i)
  9.     {
  10.         printf("Entre com o sexo : (m - homens / f - mulheres)\n");
  11.         opt = getche();
  12.  
  13.         switch(opt)
  14.         {
  15.             case 'm':
  16.             printf("\nEntre com a idade :\n");
  17.             scanf("%d",&age);
  18.             if (age>=18)
  19.             {
  20.                 malecounter++;
  21.             }
  22.             break;
  23.  
  24.             case 'f':
  25.             printf("\nEntre com a idade :\n");
  26.             scanf("%d",&age);
  27.             if (age>=18)
  28.             {
  29.                 femalecounter++;
  30.             }
  31.             break;
  32.  
  33.             default:
  34.             printf("Entrada invalida!\n");
  35.         }
  36.     }
  37.  
  38.     printf("%d homens e %d mulheres maiores de idade\n",malecounter,femalecounter);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment