I'm now beginning to study programming and on account of that I'm using VisualG to be easier to pick up on programming logic. It turns out that I'm trying to develop an algorithm that guesses the age of the person. It's pretty simple, but I'm not getting any details on this algorithm.
algoritmo "valores"
var
N1,S,S2: inteiro
inicio
Escreva ("Olá, vou adivinhar a sua idade. Pense em um numero de 1 a 10: ")
Leia (N1)
S <- N1 * 2
Escreva ("OK, multipliquei esse numero por 2 e a soma é ",S,". Agora vou adicionar 5")
S <- N1 + 5
Escreva ("A soma entre"
fimalgoritmo
This is incomplete as you can see. I wanted to put in the last line of code the number of the variable S
before it was modified by + 5
. I can not explain it right, but I'll give you an example:
Let's suppose that the person chooses the number 5. The program will do x2 that will give 10 and soon after that I wanted that in the last line of code that 10 appeared in the variable "N" and then at the end of the command write appear or "15". Something like "The sum between 10 and 5, is 15".
How do I do this?
Thank you all for responding.