diogoAlves

IFF/Introdução à Programação/Lista/49

Feb 22nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. //IFF - Introdução à Programação
  2. //Lista de Exercícios - 49
  3. #include<stdio.h>
  4. #include<locale.h>
  5. #include<string.h>
  6.  
  7. int main(){
  8.     setlocale(LC_ALL,"Portuguese");
  9.     char sexo[10], resposta[3];
  10.     int i, numeroHomens=0, numeroMulheres=0, naoHomens=0, simMulheres=0, totalSim=0, totalNao=0;
  11.     for (i=0;i<3;i++){
  12.         setbuf(stdin,NULL);
  13.         printf("Entre com seu gênero (Masculino/Feminino): ");
  14.         gets(sexo);
  15.         printf("Você gostou do novo produto?(Sim/Não) ");
  16.         gets(resposta);
  17.         if(stricmp(resposta,"Sim")==0) totalSim++; else totalNao++;
  18.         if(stricmp(sexo,"Masculino")==0){
  19.             numeroHomens++;
  20.             if(stricmp(resposta,"Sim")!=0) naoHomens++;
  21.         }else{
  22.             numeroMulheres++;
  23.             if(stricmp(resposta,"Sim")==0) simMulheres++;
  24.         }
  25.     }
  26.     if(numeroHomens==0) numeroHomens=1;
  27.     if(numeroMulheres==0) numeroMulheres=1;
  28.     printf("O número total de pessoas que responderam sim foi %d.\nO número total de pessoas que responderam não foi %d.\nA porcentagem de pessoas do sexo feminino que responderam sim foi %d%%.\nA porcentagem de pessoas do sexo masculino que responderam não foi %d%%.",totalSim,totalNao,(simMulheres*100)/numeroMulheres,(naoHomens*100)/numeroHomens);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment