Selasa, Mei 15, 2018

Show Integer Randomly Pascal Programming

To show integer randomly using pascal programming language, we use a function which called "randomize" function, the randomize function is typed after begin:
begin
  randomize;
end.

For example we will show integer randomly from 0 to n, then we type syntax:
writeln(random(n+1));

So that our program syntax will be:
begin
  randomize;
  writeln(random(n+1));
end.

For example we change the program become:
begin
  randomize;
  writeln(random(2));
  readln
end.
It mean integer will be shown randomly are between o to 1, and will never show number 2, try to run the program.

For example we will show integer randomly from 0 to 10, then our program syntax will be:
begin
  randomize;
  writeln(random(11));
  readln
end.
It mean integer will be show randomly are between 0 to 10, and will never show number 11, try to run the program

See also the tutorial on video mode:


Hopefully useful...

0 komentar: