Variable type float does not receive valuation [closed]

-4

Here's a snippet of code:

#include <stdio.h>
#include <stdlib.h>

#define MVAIN  0.8592;
#define MVAOUT 1.0282;
#define ICMS 0.29;

float ProdValue = 0, MVA = 0, ResultValue1 = 0, ResultValue2 = 0, ResultValue3 = 0;

int main(){
    printf("Indique o valor dos produtos da nfe que contenham ST \n");
    scanf ("%f", &ProdValue);   

    printf ("O valor dos produtos é:  %f \n ", &ProdValue);


    printf ("Informe se o MVA é fora ou dentro do estado \n");
    scanf ("%f", &MVA) ;


if(MVA == 1) {
    ResultValue1 =  ProdValue*MVAIN; //926,23
    ResultValue2 =  ResultValue1+ProdValue; //2004,25

    ResultValue3 =  ResultValue2*ICMS; //581,23
    ResultValue2 =  ResultValue1-ResultValue2; //345,00

    printf ("O valor a recolher é %0.2f \n", ResultValue2);


    } if (MVA == 2) {
        ResultValue1 =  ProdValue*MVAOUT; //926,23
        ResultValue2 =  ResultValue1+ProdValue; //2004,25

        ResultValue3 =  ResultValue2*ICMS; //581,23
        ResultValue2 =  ResultValue1-ResultValue2; //345,00


        printf ("O valor a recolher é %0.2f \n", ResultValue2);     
    
asked by anonymous 19.03.2017 / 18:33

1 answer

2

In a good compiler the code neither compiles. If compiling is worse because the code is full of errors. I will not even mention storing monetary value with float being an error . The code is confusing, too complicated and has logic error. I got better, but it's not good yet. It was not very clear the error, after I corrected the errors that prevented the compilation no error happened.

#include <stdio.h>

#define MVAIN  0.8592f
#define MVAOUT 1.0282f
#define ICMS 0.29f

int main(){
    printf("Indique o valor dos produtos da nfe que contenham ST\n");
    float ProdValue = 0;
    scanf("%f", &ProdValue);   
    printf("O valor dos produtos é: %0.2f\n", ProdValue);
    printf("Informe se o MVA é fora ou dentro do estado\n");
    int MVA = 0;
    scanf("%d", &MVA);
    float ValorMVA = ProdValue * (MVA == 2 ? MVAOUT : MVAIN);
    printf ("O valor do MVA é %0.2f\n", ValorMVA);
    float ValorComMVA = ProdValue + ValorMVA;
    printf ("O valor total é %0.2f\n", ValorComMVA);
    float ValorIcms = ValorComMVA * ICMS;
    printf ("O valor do ICMS é %0.2f\n", ValorIcms);
    float Diferenca = ValorMVA - ValorIcms;
    printf ("O valor a recolher é %0.2f\n", Diferenca);
}

See running on ideone . And at Coding Ground . Also put it on GitHub for future reference .

    
19.03.2017 / 21:13