Guessing Game

$ ./ - Guess a number between 1 and 100

Enter guess 1: 50
Enter guess 2: 25
Enter guess 3: 40
Correct! That took 3 guesses.
Please enter your name: Brendan Gregg
Previous high scores:
Fred Nurk 5
Brendan Gregg 3

This is a guessing game written in several different programming languages as a comparison. You guess a number between 1 and 100 and your score is saved to a high score list file.

Example output is shown on the right. Also see the longer example.

This game was written to demonstrate the difference between several languages through the same program. The program itself covers many programming fundamentals: variable declaration and manipulation (strings and integers), screen output, keyboard input, loops, if statements, file input, and file output.

Programs below. These are also on github (check out the "language statistics").


Ada bash BBC BASIC BCPL C Common Lisp C++ csh DTrace euphoria Fortran gawk GW-BASIC java ksh Logo Modula-2 nawk Pascal Perl PostScript Python QBASIC Ruby Scheme sh SPARC assembly Tcl Turbo Pascal x86 assembly Yorick zsh

Work in Progress

Algol 60 Batch C64-BASIC INTERCAL (output)


awk is a powerful text reporting tool written for Unix in 1977, it now appears on many OSs. Interpreted. (Aho, Weinberger, Kernighan).
BBC BASIC was developed in 1980 as an improved version of BASIC, influenced by what Acorn was planning.
bash is the GNU Bourne Again Shell, a sh and POSIX compatible shell designed with interactive enhancements. (B. Fox & C. Ramey).
Batch is the MSDOS, Win95, Win98 version of batch scripting, not WinNT or Win2000 (which are more functional).
C is a compiled language written in 1972 with the rewrite of Unix in C. Follows a solid specification. Fast. (Dennis Ritchie, Brian Kernighan).
C++ is a compiled object orientated language based on C, released in 1985. Features include data abstraction. (Bjarne Stroustrup).
C64-BASIC Commodore 64 BASIC ver 2.
csh is the C-Shell, a scripting language for Unix, created in 1978. (Bill Joy).
euphoria is a compiled and interpreted language for MSDOS that resembeles C, and is suprisingly powerful.
Fortran itself dates back to 1957, g77 (GNU Fortran-77) was used here. Fortran is a compiled language.
GW-BASIC is the Microsoft GW-BASIC language, an interpreted derivative of BASIC, 1982 - 1988.
ksh is the Korn shell, a powerful scripting language first written in 1982 for Unix (major updates '88, '93). It now runs on many OSs. (David Korn).
INTERCAL was developed in 1972, the same year as many other fine languages. INTERCAL's features are amazing, and it is still ahead of the times. I used the both the C-INTERCAL and J-INTERCAL compilers. (D. Woods & J. Lyon)
Logo was developed in 1967 at MIT, and is used as an educational language that can instruct a turtle to draw graphics. The UCB Logo distribution was used here.
Perl is a powerful scripting language first released in 1987 for system administration. Runs on any OS. Interpreted (+ some compilers exist). (Larry Wall).
PostScript is a page description language from Adobe in 1985, first adopted by the Apple laser writer. GhostScript (gs) was used here.
Python is an object orientated scripting language first released in 1991. Runs on many OSs. (Guido van Rossum).
QBASIC is the MSDOS Q-BASIC language, an interpreted derivative of BASIC, 1987 - 1992.
sh is the Bourne Shell, a scripting language for Unix released in 1978. Lightweight. Based on ALGOL-68. (SR Bourne).
x86 assembly the example here is for gcc on a Pentium processor.
Yorick An interpreted language suited for scientific simulations. It has graphical capabilities, and runs on many OSes. website.
zsh is the Z Shell, an enhanced shell for both programming and interactive use. (Paul Falstad).

Operating Systems

Where possible these programs have been tested on Solaris 9, RedHat 7.1 Linux and Windows 98.

Last updated: 14-May-2006