How to create an indeterminate algorithm using visualg?

I need to create an algorithm that returns me different values each time it runs, even getting the same input values.

Aims to solve a question where I need to analyze the generation of a certain living being that is more likely to have no children than to have, and create an algorithm that calculates its generations as long as it has children, and says that it has gone extinct when there are no more children.

Author: YODA, 2016-05-03

1 answers

You can say that by putting a value in the variable x, it will make a draw, ai every time you enter the same value will give a different value.

Example:

    var:
    x:inteiro; //Valor a ser inserido
    resultado:inteiro
    null:caracter
inicio
aleatorio on
    resultado
    aleatorio off
escreval("Digite o valor de x")
leia(x)
se x>=1 entao
escreval("resultado é= ")
leia(resultado)
senao
escreval("Campo vazio")
leia(null)

fimse
fimalgoritmo

Https://www.youtube.com/watch?v=nUxdrZLj9uk

I hope I helped, even though I was rusty in portugol

 1
Author: Yanka Santos, 2016-05-03 19:42:10