Post Reply 
What Was Your First Programming Language?
07-08-2015, 08:27 AM
Post: #72
RE: What Was Your First Programming Language?
(07-08-2015 06:46 AM)Thomas Klemm Wrote:  That was one of the first programs I keyed in into a calculator. Shortly after I got an HP-41CV.

Of course, I have a version of the number guessing game for the 41:
Code:

001 LBL "GUESS"
002 FIX 0
003 CF 29
004 LBL a
005 13
006 +
007 STO 08
008 0
009 STO 02
010 29
011 ENTER^
012 ENTER^
013 ENTER^
014 .25801793
015 LBL 00
016 *
017 FRC
018 DSE 08
019 GTO 00
020 100
021 *
022 INT
023 STO 01
024 CLX
025 "GUESS?"
026 PROMPT
027 LBL A
028 RCL 01
029 X>Y?
030 "TOO LOW"
031 X<>Y
032 X>Y?
033 "TOO HIGH"
034 X=Y?
035 GTO 01
036 1
037 ST+ 02
038 AVIEW
039 STOP
040 LBL 01
041 "GOT IT IN"
042 ARCL 02
043 |-" TRIES"
044 AVIEW
045 RTN

Usage:
1. Enter program and switch to USER mode
2. Enter random integer, 1 <= R <= 50 XEQ [ALPHA] GUESS [ALPHA]
3. Program prompts with "GUESS?"
4. Enter guess, and press A
5. Repeat step 4 until successful
6. For a new number, press [SHIFT] A

And since I've brought the topic back to HP calculators, here's a version in Microsoft BASIC which should adapt to the 71B almost without change:
Code:

10 REM Guessing Game
20 REM Programmed in Microsoft BASIC
30 REM 9/21/81
40 LET N = INT(99*RND(1)+1)
50 PRINT "I'm thinking of a number between 1 and 100"
60 PRINT "You've got to try to guess it."
70 INPUT "What's your guess";G
80 IF G > N THEN PRINT "Too high!"
90 IF G < N THEN PRINT "Too low!"
100 IF G = N THEN 120
110 GOTO 70
120 PRINT "You've got it!!!"
130 GOTO 40
140 END

--- Les
[http://www.lesbell.com.au]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: What Was Your First Programming Language? - Les Bell - 07-08-2015 08:27 AM



User(s) browsing this thread: 6 Guest(s)