1
I’m doing some algorithms on Visualg and came across the following error:
Error in assigning values to variable d: REAL to INTEGER
My code is this one:
Algoritmo "acertoMiseravi"
d: inteiro Inicio
escreval ("Digite dois números")
leia (n1, n2)
se n2 = 0 então
escreval ("Impossivel Dividir")
senão
d <- (n1 / n2) //essa linha aqui tá dando erro
escreva ("Divisão = ", d)
fimse Fimalgoritmo
What is wrong?
I had declared the variables, but I had taken them off the topic and I can’t remember why, kk. The error was occurring because I was using an integer type variable in a division that would result in a real number, but thank you very much for the tip and help.
– Anderson Trimont
If you want the split result to be an integer use the (integer division) operator and not / (real division).
– anonimo