QBasic handles math calculations using standard computer operators: + total = 5 + 3 - Subtraction diff = 10 - 4 * Multiplication prod = 4 * 2 / quot = 20 / 5 ^ Exponents (Power) sq = 3 ^ 2 (3 squared) Conditional Logic (Making Decisions)
CIRCLE (320, 240), 50, 4 LINE (100, 100)-(200, 200), 2, BF END
What do you want to build next (calculator, quiz game, math tool)?
To make your programs interactive, use the INPUT command: qbasic programming for dummies pdf
PRINT "Hello, World"
CLS SCREEN 12 ' DRAW A CIRCLE: CIRCLE (X, Y), Radius, Color CIRCLE (320, 240), 100, 4 ' DRAW A LINE: LINE (X1, Y1)-(X2, Y2), Color LINE (100, 100)-(200, 200), 2 END Use code with caution. Cheat Sheet: Common Error Codes Error Message What it Means How to Fix It A typo in your command. Check for misspelled words or missing punctuation. Type Mismatch Trying to mix text and numbers. Make sure strings have $ and numeric variables do not. Subscript Out of Range Accessing an item outside array limits. Check your array dimensions. Division by Zero Dividing a number by zero. Add an IF statement to ensure the divisor isn't 0.
Once you're comfortable with the basics, try these increasingly challenging projects to develop your skills: Check for misspelled words or missing punctuation
To write your first program, you only need to master a few "power words": The megaphone. It displays text or numbers on the screen. PRINT "Hello, World!"
Use this when you know exactly how many times you want to repeat an action.
While no longer widely used in professional modern development—having been replaced by languages like Python or C++—QBasic remains a popular educational tool for understanding the logic of computer programming. Subscript Out of Range Accessing an item outside
Notice how we used age + 1 inside the PRINT statement? QBasic automatically calculates the math before displaying the result. 6. Conditional Logic: Making Decisions ( IF...THEN )
Created by Microsoft in the 1980s and included with MS-DOS and early Windows versions, QBASIC requires no complex installations, no semicolon-induced headaches, and no object-oriented confusion. It lets you focus purely on — the same fundamentals that power every modern language.
This program demonstrates several important programming concepts working together: clear screen command (CLS), user input handling, string comparison with UCASE$ (converts to uppercase), score tracking with variables, conditional branching with IF...ELSEIF, and friendly output formatting.
name$ = "Sarah" PRINT "Hello, "; name$; "! Welcome to QBASIC."