PSeInt Azar: random numbers
Gives a random whole number from 0 up to the given number minus one. It can change every run, like rolling a die.
- Group:
- Math Functions
- Template
Azar
Opens the editor with this example loaded. Run it step by step and watch the flowchart.
Worked example
A complete algorithm, ready to copy and run.
Algoritmo Example dado <- Azar(6) + 1 Escribir dadoFinAlgoritmoOutput
dado is a number from 1 to 6.
This is what the console shows when the example runs.
2Common mistake
Azar(6) gives 0 to 5; that's why you add 1 to simulate a die.
In a flowchart
This is how it appears in a flowchart, with the same shapes Codoritmo draws.
Template
The general form. Replace what's inside < > with your own data.
Azar(<limite>)Examples that use it
Programs from the example library where it appears, from the simplest to the most complete.
Hangman
Guess a secret word letter by letter, with six mistakes allowed.
Advanced
More math functions
Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.