Jump to content
Sign in to follow this  
flip88

Impressão de resultado de cálculos errada

Recommended Posts

flip88

O código não está a imprimir bem os valores para Hora normal, Total Horas Extraordinarias e Dia de Trabalho. Ficam todos a 0.00 como são inicializados.

O que está mal no código?

void Calcula(trabalhador *t, salarios *s, int dim)
{
float sr=4.27, sr_total=0.00, hn=0.00;
float sb=0.00, hs=40, dt=0.00, he=0.00, he_total=0.00, css=0.11, taxa=0.00, valor_ret=0.00, salario_liquido=0.00;
int i=0, faltas;
s[i].num_interno=t[i].num_interno;
printf("Salario Base: ");
scanf("%f",&sb);
printf("Numero de faltas: ");
scanf("%d",&faltas);
printf("Numero de horas extraordinarias: ");
scanf("%d",&he);
while(s[i].num_interno!=0)
	i++;
hn=(sb*12)/(hs*52);
he_total=he*hn*1,5;
dt=hn*8;
sr_total=sr*(dt-faltas);
printf("Hora normal: %f\n",&hn);
printf("Total Horas Extraordinarias: %f\n",&he_total);
printf("Dia de Trabalho: %4.2f euros\n",&dt);
}

Obrigado.

Share this post


Link to post
Share on other sites
KTachyon

Tira os & nos printf().


“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.