INPUT "what is your age"; age%
10: PRINT "You are too young!"
20: PRINT "Still, not old enough!"
30: PRINT "So How's it feel to be in your 20's?"
40: PRINT "Just Think soon your kids will be able to drive!"
50: PRINT "Now You're over the Hill!!!"
IF age% < 10 THEN GOTO 10
IF age% >= 10 AND age% < 20 THEN GOTO 20
IF age% >= 20 AND age% < 30 THEN GOTO 30
IF age% >= 30 AND age% < 40 THEN GOTO 40
IF age% >= 40 THEN GOTO 50
END
END
END
END
END
what is your age? 23
So How's it feel to be in your 20's?
As nice as they look, GOTOs have a lot of problems, one of the major problems with GOTO's is that they offer no way
to get back to the main part of the program. This can
be solved by making labels and using GOTOs to take you back to where you came from, but that also gets pretty messy. There is
a much nicer soloution to this, that is using GOSUBs instead of GOTOs which do allow a method of getting back to where you came from.
Other problems with GOTOs are, after awhile when your program starts becoming large, it starts getting hard to remember what is going on, because GOTOs
allow unrestricted jumps to anywhere. Also, your programs become impossible to read. Teachers tend to tell the students not to use GOTO's because it is bad programming
practice, well, I'm going to tell you the same thing. But In addition to that I'm also going to say that it is okay to use GOTO's as long as you keep in mind that there is probably a better
nicer way of doing it, but it's all up to you.
Back | Tutorial Part 1 | Next |