I'm a beginner in C, I need help with a task!

-1
The statement says: 1. Knowing that a company has 20 employees, make a program that reads the salary and gender of each employee and tells you how many employees earn more than $ 1,000 and how many women earn over R $ 5,000.00. Also report the lowest and highest salary and average salary for men and women.

For the time being 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 the 20 that is the amount of employees. Can anyone help me?

    
asked by anonymous 16.12.2017 / 20:38

1 answer

0
 if(i=1){
        maior=salario;
        menor=salario;
    }

When you put in a condition i = 1, every time your code arrives at it, it will assign the value 1 in i, ie its for will never leave 1, the correct one would be if (i == 1)

And by your program you should delete it, because it does not make sense, you already put it below the conditions that define the lowest and highest salary.

    
16.12.2017 / 21:02