REM ADD TWO NUMBERS INPUT A INPUT “ENTER B”;B LET C=A+B PRINT “SOM”;C END
Write, Run & Share BASIC code online using OneCompiler's BASIC online compiler for free. It’s a simple, easy-to-use playground to learn and explore the fundamentals of BASIC programming. The compiler supports classic BASIC syntax, ideal for learning or refreshing the basics of structured programming.
BASIC (Beginner's All-purpose Symbolic Instruction Code) is one of the earliest programming languages designed to be easy for beginners. Originally developed in the 1960s, it emphasizes simplicity and readability, making it an ideal first language. Many dialects exist, such as QBASIC, FreeBASIC, and Microsoft BASIC.
The following is a sample BASIC program that asks for a user's name and displays a greeting:
PRINT "Hello, World!"
In BASIC, you can take input from the user using the INPUT
keyword. String variables usually end with $
, and numeric variables can be declared without a suffix.
INPUT "Enter your age: "; age
PRINT "You are "; age; " years old."
$
(e.g., name$
)x
, score
)Operator | Description |
---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
^ | Exponentiation |
IF score >= 50 THEN
PRINT "You passed!"
ELSE
PRINT "You failed."
END IF
FOR i = 1 TO 5
PRINT i
NEXT i
i = 1
WHILE i <= 5
PRINT i
i = i + 1
WEND
10 PRINT "Hello, World!"
20 GOTO 10
This guide provides a quick reference to BASIC programming syntax and features. Start coding in BASIC using OneCompiler’s BASIC online compiler today!