Guessing Game 1

 [ Table of Contents ] | [ Disk Image ]

Guessing Game 1 is from page 82 of the Action! Programming Language Reference Manual.



This Action! program shows how to display information to the screen, retrieve information from the user, and generate random numbers.

; EXAMPLE #2
; FROM ACTION! REF MAN PG 82

PROC guesswhile()
;*** This procedure plays a guessing game with
;the user, using a WHILE loop to keep the game 
;going

   BYTE num, ;the number to guess
        guess=[200] ;guess is initialized to an
                    ;impossible value
         
   PrintE("Welcome to the guessing game. I'm")
   PrintE("thinking of a number from 0 to 100")
   num=Rand(101) ;gets the number to guess
   WHILE guess<>num
      DO ;start of WHILE loop
      Print("What's your guess? ")
      guess=InputB() ;get user's guess
      IF guess<num THEN ;guess too low
         PrintE("Too low, try again")
      ELSEIF guess>num THEN ;guess too high
         PrintE("Too high, try again")
      ELSE
         PrintE("Congratulations!!!!")
         PrintE("You got it")
      FI ;end of guess testing
      OD ;end of WHILE loop
RETURN ; end of PROC guesswhile



Comments

Popular posts from this blog

Superhop ACTION!

ANALOG MAN