-1
A city hall conducted a survey among its inhabitants, collecting data on the population’s salary. The city wants to know: a) Number of people with a salary higher than R $ 2000,00.Number of people with a salary lower than R $ 2000,00The end of data reading will be with the entry of value -1 for salary.
I believe I’m not entirely wrong, but when I execute him, the first if
kind of runs over each other if
, at the time of counting the number of people counts only the number of the first if
that I put.
#include <stdlib.h>
#include <stdio.h>
int contador1=0,contador2=0, salario;
main()
{
do{
printf("Digite o seu salario (para cancelar digite -1): ");
scanf("%f", &salario);
if(salario>=2000){
contador1=contador1+1;
}
if(salario<2000){
contador2=contador2+1;
}
}while(salario>0);
printf("Pessoas com salario maior de 2000.00 reais: %d \ne menor de 2000.00 reais: %d\n",contador1, contador2);
system("pause");
return 0;
}
Wow. I forgot it, because I actually spent SO much time trying to solve it that I ended up changing so many things, I changed variables, I added, I took.. and I ended up forgetting that, thank you very much! I guess I wouldn’t have realized the mistake.
– Luciano Balestrin Correa