0
I am starting now to study programming and because of that I am using Visualg to be easier to get the programming logic. It turns out I’m trying to develop an algorithm that can guess a person’s age. It’s very 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 variable number S
before it is modified by + 5
. I can’t explain it properly, but I’ll give you an example:
Let’s assume that the person chooses the number 5. The program will make x2 that will give 10 and soon after I wanted that in the last line of code appear this 10 in the variable "N" and then at the end of the command write appear the "15". It would appear something like "The sum between 10 and 5, is 15".
How do I do it?
Thank you to all who answer me.
Thank you so much! I’ll try to do that
– Arthur