1. Home
  2. /
  3. Qbasic
  4. /
  5. Graphics and Input

Graphics and Input - Qbasic Typing CST Test

Loading…

Graphics and Input — Qbasic Code

Shows QBasic's graphics capabilities with drawing commands and user interaction.

REM QBasic graphics and user input example
SCREEN 12
CLS

REM Draw colorful borders
COLOR 9
LINE (0, 0)-(639, 479), , B

REM Title text
COLOR 14
LOCATE 2, 30
PRINT "QBasic Graphics Demo"

REM Draw a house
COLOR 12
LINE (200, 200)-(400, 350), , BF  'House body
COLOR 10
LINE (200, 200)-(300, 100)  'Roof left
LINE (300, 100)-(400, 200)  'Roof right
LINE (200, 200)-(400, 200)  'Roof bottom

REM Draw a door
COLOR 6
LINE (280, 260)-(320, 350), , BF

REM Draw windows
COLOR 11
LINE (220, 240)-(260, 280), , BF
LINE (340, 240)-(380, 280), , BF

REM User interaction
COLOR 15
LOCATE 20, 20
PRINT "Enter your name: ";
INPUT name$
LOCATE 22, 20
PRINT "Hello, "; name$; "! Press any key to exit."

REM Wait for keypress
WHILE INKEY$ = "": WEND
END

Qbasic Language Guide

QBasic is a beginner-friendly, procedural programming language and integrated development environment (IDE) developed by Microsoft for DOS systems, widely used in the 1980s and 1990s for teaching programming and creating simple applications.

Primary Use Cases

  • ▸Teaching programming basics
  • ▸Learning procedural programming
  • ▸Creating simple DOS-based utilities
  • ▸Developing text-based games
  • ▸Educational exercises in logic and algorithms

Notable Features

  • ▸Simple, beginner-friendly syntax
  • ▸Interactive IDE with immediate feedback
  • ▸Built-in support for loops, conditionals, and subroutines
  • ▸Basic graphics and sound commands
  • ▸File handling and text-based I/O

Origin & Creator

Created by Microsoft in 1985 as a simplified version of GW-BASIC, maintained until the mid-1990s.

Industrial Note

QBasic was mainly used in education, early DOS-based games, small utilities, and teaching programming fundamentals, with limited industrial application today.

Quick Explain

  • ▸QBasic provides a simple and interactive IDE for writing, running, and debugging BASIC programs.
  • ▸Supports procedural programming with loops, conditionals, and subroutines.
  • ▸Includes built-in commands for input/output, file handling, and simple graphics.
  • ▸Ideal for learning programming concepts and logic before moving to advanced languages.
  • ▸Programs are interpreted or compiled to simple executable code under DOS.

Core Features

  • ▸PRINT, INPUT for text output and input
  • ▸FOR...NEXT, WHILE...WEND, IF...THEN for control flow
  • ▸GOSUB and SUB for subroutines
  • ▸Simple graphics with LINE, PSET, CIRCLE commands
  • ▸CLS and SCREEN commands for basic screen management

Learning Path

  • ▸Learn BASIC syntax and commands
  • ▸Understand variables and data types
  • ▸Practice loops and conditionals
  • ▸Write subroutines and modular programs
  • ▸Develop small games and utilities

Practical Examples

  • ▸Create a simple number guessing game
  • ▸Write a calculator for arithmetic operations
  • ▸Draw geometric shapes using graphics commands
  • ▸Read and write text files
  • ▸Develop menu-driven programs with subroutines

Comparisons

  • ▸QBasic vs GW-BASIC: QBasic has IDE and structured commands; GW-BASIC older interpreter
  • ▸QBasic vs Turbo Pascal: QBasic simpler, Turbo Pascal more structured and compiled
  • ▸QBasic vs Python: QBasic DOS-based and procedural; Python modern and versatile
  • ▸QBasic vs C: QBasic beginner-friendly; C low-level and faster
  • ▸QBasic vs Java: QBasic procedural; Java object-oriented and cross-platform

Strengths

  • ▸Easy to learn for beginners
  • ▸Immediate execution in the IDE
  • ▸Good for understanding programming logic
  • ▸Lightweight and simple setup
  • ▸Supports quick prototyping of small programs

Limitations

  • ▸Limited to DOS environment
  • ▸No object-oriented features
  • ▸Outdated compared to modern languages
  • ▸Not suitable for large-scale applications
  • ▸Graphics and sound support is minimal

When NOT to Use

  • ▸Modern application development
  • ▸Web or mobile programming
  • ▸Large-scale software or enterprise apps
  • ▸Object-oriented programming exercises
  • ▸Projects requiring advanced graphics or networking

Cheat Sheet

  • ▸PRINT 'text' - display text
  • ▸INPUT variable - get user input
  • ▸FOR i = 1 TO 10 … NEXT i - loop
  • ▸IF condition THEN … ELSE … END IF - conditional
  • ▸SUB name … END SUB - define subroutine

FAQ

  • ▸Is QBasic free? -> Yes, distributed with MS-DOS and Windows 95/98.
  • ▸Can QBasic run on modern systems? -> Yes, via DOSBox.
  • ▸Does QBasic support graphics? -> Yes, basic 2D graphics commands.
  • ▸Can QBasic create executable files? -> Yes, compile to EXE in DOS.
  • ▸Is QBasic still used? -> Rarely, mostly for education and nostalgia.

30-Day Skill Plan

  • ▸Week 1: Learn PRINT, INPUT, variables, and types
  • ▸Week 2: Practice loops and IF statements
  • ▸Week 3: Implement subroutines and GOSUB
  • ▸Week 4: Work with text files and arrays
  • ▸Week 5: Build small text-based games and projects

Final Summary

  • ▸QBasic is a beginner-friendly procedural programming language for DOS.
  • ▸Supports loops, conditionals, subroutines, file I/O, and simple graphics.
  • ▸Primarily used for learning programming concepts and small DOS applications.
  • ▸Lightweight IDE allows interactive coding and debugging.
  • ▸Now mostly used for educational purposes or retro computing.

Project Structure

  • ▸Main program file (*.BAS) - contains source code
  • ▸Optional external data files for input/output
  • ▸Subroutine libraries (if needed)
  • ▸Executable (*.EXE) after compilation
  • ▸Documentation files for program explanation

Monetization

  • ▸QBasic is free and educational
  • ▸Commercial use historically limited to DOS utilities
  • ▸Mostly used today for learning or retro projects
  • ▸No modern monetization ecosystem
  • ▸Supports learning foundational programming skills

Productivity Tips

  • ▸Use subroutines to reduce code repetition
  • ▸Test frequently with small program chunks
  • ▸Organize code logically with comments
  • ▸Use arrays for structured data
  • ▸Keep programs simple and clear

Basic Concepts

  • ▸Variable - storage for data (INTEGER, STRING, etc.)
  • ▸Control Structures - IF, FOR, WHILE statements
  • ▸Subroutine - reusable code block using SUB/GOSUB
  • ▸Function - returns a value from calculations
  • ▸Statement - single executable command in program

Official Docs

  • ▸Microsoft QBasic manuals (archived)
  • ▸QB64 official website for modern QBasic compiler
  • ▸DOSBox documentation for running QBasic

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher