QBASIC

Chapter 6: First Steps in Programming

What is a Program?

A program is a set of instructions given to a computer to perform a specific task.

These instructions are written in a language that the computer can understand and execute.

What is a Programming Language?

A programming language is a language used to write programs and communicate instructions to a computer.

Some common examples of programming languages include:

  • C
  • C++
  • Java
  • Python
  • JavaScript

These languages help programmers create applications, websites, games, and software systems.


What is QBASIC?

QBASIC is a simple programming language used mainly for learning basic programming concepts.

Key Facts About QBASIC

  • BASIC stands for Beginner’s All-purpose Symbolic Instruction Code.
  • QBASIC was designed for beginners to learn programming easily.
  • It was developed by:
    • Professor John G. Kemeny
    • Thomas E. Kurtz
  • They developed BASIC at Dartmouth College, USA.
  • BASIC was first introduced in the 1960s.
  • QBASIC is commonly used to create small programs for learning purposes.

Elements of a Programming Language

Programming languages are made up of several basic elements.

Character Set

A character set is a group of symbols used to write programs.

It includes:

1. Digits

Numbers from:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

2. Letters

Alphabet letters from:

A to Z

a to z

3. Special Characters

Examples:

+   -   *   /   %  

<   >   =  

(   )   ;   :  

!   $   #   ?

Constants

A constant is a value that does not change during program execution.

Constants remain fixed throughout the execution of a program.

There are two types of constants:

  1. Numeric Constants
  2. String Constants

1. Numeric Constants

A numeric constant is a value on which mathematical operations can be performed.

Operations include:

  • Addition
  • Subtraction
  • Multiplication
  • Division

Features of Numeric Constants

  • Consist of digits
  • Can be positive or negative
  • Used in calculations

Types of Numeric Constants

Integer Type

Whole numbers without decimal points.

Examples:

1

234

456

-50

Real Number Type

Numbers that include decimal points.

Examples:

7.8

0.765

-12.45

2. String Constants

A string constant is a value on which mathematical calculations cannot be performed.

It consists of letters, numbers, or special characters.

Features of String Constants

  • Also called alphanumeric constants
  • Always enclosed within double quotes (" ")
  • Can contain letters, digits, or symbols
  • In BASIC, strings can be up to 255 characters long

Examples:

"vikasmishra"
"vmsmprogramming"
"1234"
"Hello World"

Variables

A variable is a value that can change during program execution.

A variable represents a memory location in the computer where data is stored.

Each variable has:

  • A name
  • A value

The value of a variable can change while the program runs.

There are two types of variables:

  1. Numeric Variables
  2. String Variables

1. Numeric Variables

A numeric variable stores numeric values such as integers or decimal numbers.

Features of Numeric Variables

  • Stores numbers
  • Used in mathematical calculations
  • Must follow naming rules

Example:

marks = 20

Where:

  • marks → Variable name
  • = → Assignment operator
  • 20 → Numeric value

Rules for Naming Numeric Variables

  • Must begin with a letter
  • Cannot contain spaces
  • Cannot contain special characters
  • Can contain letters and numbers
  • Length should be 1 to 8 characters (in QBASIC)

Example:

num1
total
value2

2. String Variables

A string variable stores text such as words or letters.

In QBASIC, string variables must end with a dollar ($) sign.

Example:

name$ = "vmsm"

Where:

  • name$ → String variable
  • "vmsm" → String value

Features of String Variables

  • Store text or characters
  • Used for names, addresses, messages
  • Always contain values inside double quotes

Examples:

city$ = "Delhi"
message$ = "Welcome"


Comments

Post a Comment

Hello students
If you have any doubt then let me know.

Popular posts from this blog

FLOW CHART

HTML

BASIC CONCEPT OF C++