algoritmo "Calculadora"
Var
num1, num2, r: real
operacao: caractere
inicio
EscrevaL("Digite: ")
leia(num1, operacao, num2)
caso operacao "+"
r <- num1 + num2
caso operacao "-"
r <- num1 - num2
caso operacao "*"
r <- num1 * num2
caso operacao "/"
r <- num1 / num2
EscrevaL("Resultado:", r)
fimalgoritmo
Basically, it does not display the correct values, and how could I do to type direct operation, type like this: 2 + 2?
I tried to do it there, so much that I read three variables, and it did not work out.
I had to type like this:
2
+
2
So he would recognize, but, as the form I reported above, I could not do.
I entered the value 3 + 3, resulted in 9, what am I missing?
How can I improve the code / correct?