-1
The statement says: 1. Knowing that a company has 20 employees, make a program that reads the salary and sex of each employee and report how many employees earn more than R $ 1.000,00 and how many women earn more than R $ 5.000,00. Report even the lowest and highest salary and average wage among men and women.
So far I’ve done the following:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int quant_mais1000,quant_H,quant_M,mulher_mais5000,soma_H,soma_M;
float salario,menor,maior,mediaH,mediaM;
char sexo;
for(int i=1;i<=20;i++){
printf("Insira o salario: ");
scanf("%f",&salario);
printf("Insira o sexo: ");
scanf("\n%c",&sexo);
if(i=1){
maior=salario;
menor=salario;
}
if (salario>=100){
quant_mais1000++;
}
if(sexo == 'M' || sexo == 'm'){
soma_H=soma_H+salario;
quant_H++;
}
if(sexo == 'F' || sexo == 'f'){
soma_M=soma_M+salario;
quant_M++;
if (salario>=5000){
mulher_mais5000++;
}
}
if(salario>maior){
maior=salario;
}
if(salario<maior){
menor=salario;
}
}
printf("Salario acima de R$ 1000,00 e: %d",quant_mais1000);
system("pause");
return 0;
}
But the program does not stop when it reaches 20 which is the number of employees. Someone can help me?
Oops, it’s true! I forgot about that detail, thank you very much!
– Anderson Jesus