texmf-dist/doc/generic/c-pascal/prog/guess.pas
raw| 1 | program guess; |
| 2 | |
| 3 | var |
| 4 | num1, num2: integer; |
| 5 | |
| 6 | begin |
| 7 | randomize; |
| 8 | num2 := random(100); |
| 9 | |
| 10 | repeat |
| 11 | { make user guess } |
| 12 | write('Guess my number: '); |
| 13 | readln(num1); |
| 14 | |
| 15 | { check the relation } |
| 16 | if num1 = num2 then |
| 17 | writeln('Very well!'); |
| 18 | if num1 < num2 then |
| 19 | writeln('Too small.'); |
| 20 | if num1 > num2 then |
| 21 | writeln('Too big.'); |
| 22 | until num1 = num2; |
| 23 | |
| 24 | { pause } |
| 25 | readln; |
| 26 | end. |