algol-things/src/guess.a68

24 lines
687 B
Plaintext
Raw Normal View History

2025-04-06 21:37:07 +00:00
BEGIN
on logical file end (stand in,
(REF FILE f) BOOL: (print(("Goodbye!",new line));stop));
first random(ENTIER(seconds)); # Seed with current seconds #
INT random_number = ENTIER (next random * 100.0) + 1;
print(("the secret number is",random_number,new line));
print("guess a number: ");
WHILE
INT guess = read int;
IF guess < random_number THEN
print("too low, try again: ");
TRUE
ELIF guess > random_number THEN
print("too high, try again: ");
TRUE
ELSE
print(("that's right",new line));
FALSE
FI
DO SKIP OD
END