At the beginning of the code I declare the variable nome
as char
and when I try to get the nome
variable down there in the code it gives error, I already tried in several ways and that way down there until it works, but sometimes when the user asks "Do you want to continue?" and it responds s (yes), sometimes it jumps directly to the field "enter the salary of the employee:", that is. skip the part where you ask the employee's name
int cont, tinss;
char s, resp, nome[50];
float sal, novosala, val;
cont = 1;
do
{
printf("\n digite o nome do funcionario; ");
scanf("%s",&nome);
printf("\n digite o salario do funcionario: ");
scanf("%f",&sal);
if(sal <= 500)
{
novosala = sal - ((sal / 100) * 8);
val = (sal / 100) * 8;
tinss = 8;
}
else
if(sal > 500 && sal <= 1000)
{
novosala = sal - ((sal / 100) * 10);
val = (sal / 100) * 10;
tinss = 10;
}
else
if(sal > 1000)
{
novosala = sal - ((sal / 100) * 12);
val = (sal / 100) * 12;
tinss = 12;
}
printf("\n Nome: %s \n",nome);
printf("\n Salario bruto: %f \n", sal);
printf("\n Taxa de INSS: %d% \n", tinss);
printf("\n Valor de INSS %f \n", val);
printf("\n Salario liquido: %f \n", novosala);
printf("\n deseja continuar ? \n");
resp = getch();
cont = cont + 1;
}
while(resp == 's');