Hello World Example¶
The classic first program in any language.
The Program¶
How It Works¶
Line 10: PRINT "Hello, World!"
- The PRINT statement outputs text to the screen
- Text in quotes is displayed exactly as written
- The semicolon at the end is optional
Line 20: END
- Tells BASIC to stop running the program
- Always good practice to end programs with END
Running the Program¶
- Type each line (the line number, then the statement)
- Press Enter after each line
- Type
RUNand press Enter - You should see:
Hello, World!
Variations¶
With Variables¶
With Input¶
When you run this:
Multiple Greetings¶
Common Mistakes¶
Forgetting the quotes:
Must use quotes for text:PRINT "Hello, World!"
Missing line numbers:
Every program line needs a number:10 PRINT "Hello"
Next Steps¶
Now that you've written your first program, try: - Loop Examples - Repeating actions - Variables - Storing data - INPUT Statement - Getting user input