Does anyone help me with this?

1

5) Make a program that receives the base salary of an employee, calculate and show your salary to receive, knowing that the employee has a bonus of $ 50 and pays 10% tax

#include <stdio.h>
int main()

{
float sal,imposto,s_final;
printf(" CALCULO DE SALARIO \n \n");

printf("Digite seu salario: ");
scanf("%f",&sal);

imposto= sal/100 * 0.1;
s_final = sal-imposto+50;

printf("Salario a receber: %f reais \n",&s_final);
printf("Valor dos impostos: %f reais",&sal);
return 0;
}

    
asked by anonymous 19.03.2018 / 22:40

2 answers

0

O & (and commercial) is used to pass the address of a variable, that is, when you do: printf ("Salary to receive:% f actual \ n", & s_final); printf ("Value of taxes:% f real", & salt);

The printf function is expecting a float, because in the string it has "% f", but "& s; end" represents the address that the value of the variable "s_final" is stored.

To fix this, simply remove & in the printf function call.

    
20.03.2018 / 00:32
1

Hello I was visualizing your code and the logic is correct, however, you forgot that the "&" is only used for scanf and not for printf (if you use for print it will take the address of the memory and not the content).

I rephrased the code:

 #include <stdio.h>
 int main()
 {
 float sal,imposto,s_final;
 printf(" CALCULO DE SALARIO \n \n");
 printf("Digite seu salario: ");
 scanf("%f",&sal);

 imposto= (sal*10)/100;
 s_final = sal-imposto+50;

 printf("Salario a receber: %f reais \n",s_final);
 printf("Valor dos impostos: %f reais",sal);

 } 

I hope I have helped you!

    
20.03.2018 / 00:36