What is a sub programs in qbasic?

1 answer

Answer

1077301

2026-07-27 19:01

+ Follow

Sub programs allow you to break up one long program; into being a series of much smaller tasks; usually, controlled by a main program. Example...

====

As you can see from the above 2 examples; the 2nd example, although longer, creates code that is much clearer and simpler to read. Even non-programmers should be able to figure out what the 'Main Program' section is doing.

NOTE: There are certain rules for the use of sub-routines. Such as the sub routine should confine itself to doing just 'one' task at a time. So, SUB clearScreen...does just 'one' job, alone...which is to (CL)ear the output (S)creen. It does NOT clear the screen AND get the user to input a number. This makes it quicker and easier to debug programs; as you know exactly where the code is going wrong; so, for example, if the screen didn't clear, properly...then, look at the Sub-routine called: SUB clearScreen. If the title didn't appear; then, look at the Sub-routine called: SUB printTitle. /-Etc.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.