Source code does not compile [closed]

-1
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {

    float parede, litros;

    printf ("Calcular litros de tintas  por metros quadrados.\n");
    printf ("Digite a metragem da parede(em metros ao quadrado):");
    scanf("%f", parede);

    if (litros = parede*2/10)
        printf("sao necessarios (litros):");
        scanf("%f", litros);

system ("pause");
return 0;
}
    
asked by anonymous 22.11.2017 / 06:52

3 answers

1

In scanf, the use of "&" is required:

scanf("%f", &parede);

The use of "if" is also not necessary because you are assigning a value to the variable "liters", not creating a condition:

litros=(parede*2)/10;

With this, in the final result, printf should show:

printf("Sao necessarios (litros): %.2f", litros);

(O% .2f has determined the number of decimal places the program will display, which in this case are 2).

With this there is no need to use "scanf" after this printf because the user will not type anything else, only the result will be printed.

I hope I have helped.

    
22.11.2017 / 11:07
0

There are some problems with your code, for example  scanf ("% f", wall); it is necessary to allocate the value of the variable with & wall) / another error is i IF that is not correct use it since there is no condition in the program (it will receive value, calculate according to the formula and only), the correct one is liters = (wall * 2) / 10; liters will receive the wall value * 2/10 and to display the values (printf ("liters)% 2f: \ n", liters); where (% .2f): will call the float variable with 2 digits after the decimal place.

    
22.11.2017 / 10:13
0

Try using:

 if (litros = parede*2)/(10){
    printf("sao necessarios (litros):");
}
    scanf("%f", &litros);

Never forget to put & when using Scanf, if you want to print only two numbers after the comma, use %. 2f when printing. A good tip is to abandon devC ++ (I think you're using it because of the system pause down there), I recommend using Eclipse for C < strong>, and has the advantage of running on Linux as well.

    
22.11.2017 / 11:24