1
I’m starting programming now and to learn new things I’m trying to make a C code that calculates whether the user receives more or less than 3 minimum wages. However when doing the sum of the last 4 user salaries the result is inconsistent with the entered values.
Here is the code
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int A = 998; //Salario minimo
float X, Y, Z, K; //Armazena os 4 ultimos salarios
int C = A * 3; //Calcula quanto equivale 3 salarios minimos
float D = X+Y+Z+K; //Soma os 4 ultimos salarios
printf("Digite seus 4 ultimos salarios, 1º");
scanf("%f", &X);
printf("2º");
scanf("%f", &Y);
printf("3º");
scanf("%f", &Z);
printf("4º");
scanf("%f", &K);
printf("A soma dos salarios é: %f", D);
return 0;
}
I hope you can help me.
You calculated the value of
D
before reading the values ofX
,Y
,Z
andK
?– Woss
I think that’s it, getting it now that I put the variable to calculate the value of D after reading the values. Thank you.
– Izaac Borges