Reading — step 1 of 5
Learn
Hello, BASIC
BASIC — Beginner's All-purpose Symbolic Instruction Code — was created at Dartmouth College in 1964 with a radical goal: computing for everyone, not just scientists with punch cards. It worked. By the early 1980s virtually every home computer booted straight into a BASIC prompt, and a generation learned to program on it. This course uses FreeBASIC (the fbc compiler): a free, modern compiler that keeps the classic QuickBASIC syntax but produces fast native executables. Your code here is genuinely compiled and run — same as C, just friendlier.
Your first program
PRINT "Hello, BASIC!"
That one line is a complete program. No class, no main function, no imports. This is BASIC's founding idea: the language should meet the beginner, not the other way around. Execution starts at the top of the file and runs downward, line by line.
Ground rules before anything else:
- Keywords are case-insensitive.
PRINT,print, andPrintare the same word. (Convention here: keywords in CAPS, like the classics.) - Text inside quotes is NOT case-insensitive.
"Hello"and"hello"are different strings — and the grader cares. - One statement per line. No semicolon terminators like C or Java.
- Comments start with
'(a single quote) or the old-schoolREM. The compiler ignores the rest of the line.
How PRINT separates things
PRINT writes its arguments, then moves to a new line. The separator between arguments controls spacing:
PRINT "one"; "two" ' onetwo (semicolon joins with NO space)
PRINT "one", "two" ' comma jumps to the next 14-column zone
PRINT "no newline yet";
PRINT " ...same line" ' a trailing ; suppresses the newline
The comma zones exist for quick table layouts on 1980s screens. For exact output — which is what graders check — prefer ; and put any spaces you need inside the quotes yourself.
The trap: unquoted text
PRINT Hello, BASIC! ' COMPILE ERROR
Without quotes, the compiler reads Hello as a variable name. FreeBASIC's default dialect requires variables to be declared before use, so this stops with a "variable not declared" error. Museum-era BASICs were worse: they silently invented the variable and printed 0. The modern dialect turns that silent bug into a loud one — that's a feature.
A peek at input
DIM n AS INTEGER
INPUT "", n
PRINT n * 2
INPUT reads a value typed into the program. The empty "" prompt matters: plain INPUT n prints a ? prompt first, and on this platform that stray ? becomes part of your output and fails the exact-match grader. DIM is variable declaration — the entire next lesson is about it.
Your exercise
Print exactly:
Hello, BASIC!
Replace the ' PRINT "..." comment in the starter with a real PRINT. The grader compares your output character by character, and these are the mistakes it catches every day:
Hello Basic!—BASICmust be ALL CAPS, and the comma afterHellois required.- Missing the
!at the end. - Adding a second
PRINT"for good measure" — that emits an extra blank line and the match fails. OnePRINTalready ends with a newline, which is exactly what the grader expects.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…