Help with a problem of c, save operation on variable

1

It does not save the operation that is done in printf, for example 2 + 2, it does not save it in scanf, I'm just starting

#include<stdio.h> 
int main(){
float resultado;
printf("Introduce la operacion: ");
scanf("%f", resultado);
printf("El resultado de la operacion es: %f", resultado);

return 0;
}
    
asked by Jenio158 03.10.2017 в 20:02
source

1 answer

0

Change the line where you capture the value entered.

scanf("%f", &resultado);

Estro would be an example to add two entered values

#include<stdio.h> 
int main(){
float valor1, valor2, resultado;
printf("Introduce el primer valor: ");
scanf("%f", valor1);
printf("Introduce el segundo valor: ");
scanf("%f", valor2);
resultado = valor1 + valor2;
printf("El resultado de la operacion es: %f", resultado);

return 0;
}
    
answered by 03.10.2017 в 20:08