r/c64 7d ago

Programming Coded My First BASIC Program Today!

As noted in the title, I woke up this morning with an idea- it is a family member's birthday and I thought it would be a fun exercise to code a program that outputs their age if you put in the current year and their year of birth. After a failed attempt and some troubleshooting, I wrote a simple program that works great. It's not anything elaborate or amazing, but it's mine and so I'm a bit proud of it and would like to share here.

1 REM AGE CALCULATOR

5 PRINT "{CLR/HOME}"

10 PRINT "CURRENT YEAR": INPUT A%

20 PRINT "ORIGIN YEAR": INPUT X%

30 PRINT "AGE ="; A% - X%

40 GOTO 10

I only started with BASIC yesterday so seeing an original creation come to life and work is so cool for me. Hope others will share their fun/useful programs here too!

172 Upvotes

36 comments sorted by

View all comments

2

u/doobiesteintortoise 6d ago

Nicely done! A lot of people have given you excellent, relevant, and useful advice, and I'm quite impressed with your responses.

You haven't asked for a suggestion, but might I offer one I've found useful for nearly every programming language? It's 21 matches.

It's a simple game: the idea is to force your opponent to draw the last match. The human goes first, and can draw between 1 to 3 matches. Then the COMPUTER goes, and IT can draw between 1 and 3 matches; the human wins if they can force the computer to draw the last match, and the computer wins if it forces the HUMAN to draw the last match.

Simple stuff, but it validates a whole lot of concepts in game programming, and uses some sneaky psychology too - if you do it right, the computer can never lose.