I need the negative values entered by the user not to enter the calculation, and also that this negative insertion is canceled by the program.
The statement reads as follows:
A city council has conducted a survey among its inhabitants, collecting data on people's wages. The city wants to know:
- The average salary of the population.
- The highest salary.
- The number of people with salaries above R $ 1,000.00
The end of the reading of the data will happen with the entry of a negative salary.
Part of the code I've already done:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int quant_sal=0,salario_1000=0,soma=0,maior=0;
float salario=1;
printf("Insira o salario: ");
scanf("%f",&salario);
maior=salario;
while(salario>=1){
soma=soma+salario;
if(salario<=0){
printf("Salario invalido");
}
if(salario>1000){
salario_1000++;
}
if(salario>maior){
maior=salario;
}
printf("Insira o salario: ");
scanf("%f",&salario);
}
printf("A media de salario e: %.1f\n",soma/salario);
printf("O maior salario e: %d\n",maior);
printf("Salario acima de 1000 e: %d\n",salario_1000);
system("pause");
return 0;
}