victorialais

Questão 12. Homens, mulheres e suas idades

Aug 19th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5.  
  6. {
  7.     float somamulheres, idade, i, somahomens, mulheres, homens, somaidade;
  8.     float percentual_homens, percentual_mulheres, idademedia, im_mulheres, im_homens;
  9.     char sexo;
  10.  
  11.  
  12.    
  13.    
  14.    for (i=0; i<8; i++){
  15.    
  16.     printf("Digite a idade da pessoa: ");
  17.     scanf("%f", &idade);
  18.     printf ("Digite o sexo da pessoa [f/m]: ");
  19.     scanf ("%s", &sexo);
  20.     if (sexo == 'f'){
  21.         mulheres++;
  22.         somamulheres = somamulheres + idade;
  23.         somaidade = somaidade + idade;
  24.        }
  25.        
  26.        else {
  27.         homens++;
  28.       somahomens = somahomens + idade;
  29.        somaidade = somaidade + idade;
  30.        }  
  31.        }
  32. idademedia = (somaidade/8);
  33.    percentual_mulheres = (mulheres/8)*100;
  34.    percentual_homens = (homens/8)*100;
  35.    im_mulheres = somamulheres/mulheres;
  36.    im_homens = somahomens/homens;      
  37.    
  38.    
  39.    
  40.    
  41.      printf ("A idade media do grupo é %f \n", idademedia);
  42.      printf ("A idade media das mulheres é %f \n", im_mulheres);
  43.      printf ("A idade media dos homens é %f \n", im_homens);
  44.      printf ("O percentual de homens é %f % \n", percentual_homens);
  45.      printf ("O percentual de mulheres é %f % \n", percentual_mulheres);
  46.      
  47.  
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment