QBASIC

QBASIC

 

#Program: Set of instructions

#Progamming: Process of writing programs

#Programmer: Person who writes programs

#Programming language: Language used to write programs

Types of PL’s

1.     Machine: 0’s and 1’s

2.     Assembly: Mnemonics

3.     High level: English like language

#QBASIC: QBASIC is a high-level programming language developed by Microsoft Incorporation USA in 1985.

·        Stands for Quick Beginners All-purpose Symbolic Instruction Code

·        Earlier version- BASIC

·        Version of BASIC: GWBASIC, Turbo BASIC, QUICK BASIC, Visual BASIC

Features of QBASIC:

·        User friendly

·        Easy to write programs

·        Easy to understand

·        Easy to debug

·        Provides smart editor (automatically capitalizes reserved words)

 

Application file name:QB.EXE

Extension file name: .BAS

 

#Data types in QBASIC: Data type is the indicator that tells us what kind of value must be stored in a variable.

There are two types of data types used in QBASIC. They are:

(i)Numeric: Consists numeric data (1,2,3,4,9,10,….)

(ii)String: Consists alphanumeric data (“1234”, “shyam”, “p142”, …..)

 

#Variables: Variable is a location or place where the values are kept. In simple word, it is a name that stores values.

Types of variables

(i)Numeric Variable: Stores numeric data. For instance, xyz=12, AB=7, etc. Here, xyz and AB are numeric variables.

(ii)String Variable: Stores alphanumeric data. It can store only numeric, only letter or both. Example: a$=”Nepal”, add$=”Katahariya-123”, x$=”1234”, etc. Here, a$, add$ and x$ are strign variables.

String variables are identified by a dollar($) sign.

 

#Constants: Constants are the data items that remain unchanged during program execution time. In simple word, these are the fixed values that cannot be changed.

Types of constants:

(i)Numeric constants: Contains number only. Examples r=153, abc=11, etc. Here, 153 and 11 are numeric constants.

(ii)String constants: Contains alphanumeric characters. Examples a$=”January”, z$=”123-xyz”. Here, January and 123-xyz are string constants.

String constants are identified by double quotation (“ “) sign.

 

**Rules for naming a variable:

·      - A variable should always start with an alphabet.

·      - It can be up to 40 characters long.

·      - Reserved words (keywords) are not allowed.

·      - Can contain numbers and data declaration symbols (!,%,&,#,$) as suffix.

·      - Cannot start with FN.

#Keywords: The words whose meaning is already known to the computer (QBASIC) is called keywords. LET, REM, CLS, INPUT, PRINT, MID$, UCASE$, ASC, CHR$, VAL, INT, etc. are keywords.

 

#Symbolic Constant: A symbolic constant is a constant that is represented by a name, just as a variable is represented. Gravitational constant (G), acceleration due to gravity (g), and pi (π) are symbolic constants. It is defined using CONST statement.

 

#Types of numeric variables: There are four types of numeric variable. They are:

(i)Integer (n%): This variables store number with no fractional part i.e. non-decimal number. It is indicated by a% (percent) sign after the variables name as suffix. It occupies 2 bytes of space in the memory.

Integer length:

Minimum value: -32768 numbers

Maximum number value: 32767 numbers

 

(ii)Long integer (n&): This variables also stores integer value i.e. non-decimal number. It is indicated by &(ampersand) sign after the variable name as suffix. It occupies 4 bytes of space in the memory.

Long integer length:

Minimum value: -2147483648 numbers

Maximum value: 2147483647 numbers

 

(iii)Single Precision Number (n!): This variable can store single-precision values i.e. decimal or non-decimal numbers upto 7 digits. It is indicated by ! (exclamation) sign after the variable name as suffix. It occupies 4 bytes of space in the memory.

Single Precision Length:

Minimum value=-3.37*10^38

Maximum value= 3.37*10^38

 

(iv)Double Precision Number (n#): This variable can store double precision values i.e. decial as well as non-decimal values upto 15 digits and store 8 bytes of space in the memory. It is indicated by #(hash) sign after the variable name as suffix.

Double Precision Length:

Minimum value=-1.67*10^308

Maximum value=1.67*10^308

 

#String variable (n$):

String length:

Minimum value= 0 characters

Maximum value= 32767 characters

 

#Operator: Operator is a symbol sign used to perform specific operation.

Types of operator:

(i)                Arithmetic Operaotrs: Arithmetic operators are used to perform mathematicl operations like addition(+), subtraction(-), multiplication(*), division(/), exponentiation(^) and modular division(MOD).

(ii)              Relational Operators: Relational operators compares two values of same type, either numeric or string and gives the result as TRUE(non zero) or FALSE(zero). These operator are equal to(=), greater than(>), less than(<), greater than or equal to(>=), less than or equal to(<=), not equal(<>).

(iii)            Logical Operators: Logical operator combines the result of two or more relational expressions and returns either TRUE(non zero) or FALSE(zero). The commonly used logical operators in QBASIC are AND, OR and NOT. The truth table of AND, OR and NOT operators are:

(a)  AND Operator

Condition 1

Condition 2

Result

True

True

True

True

False

False

False

True

False

False

False

False

 

(b)  OR Operator

Condition 1

Condition 2

Result

True

True

True

True

False

True

False

True

True

False

False

False

 

(c)   NOT Operator

Condition

Result

True

False

False

True

(iv)            String Operators: String operator joins two or more than two string data. The plus sign(+) is used as the string operator. Combining of two strings is called concatenation. Ex: su(a$)+jit(b$)

# QBASIC Expressions: The combination of constants, variable with operators is called qbasic expression.

Types of expression:

(i)                Numeric or Arithmetic Expression: Returns a numeric value as output. Ex: a=b^2 + c^2, s=b+d

(ii)              Logical or Boolean Expression: Returns one of two logical values, either true or falese. Ex: PRINT 20>5;-1, PRINT 2>7;0 . Output is given -1 for true and 0 for false.

(iii)            String Expression: Returns string value. Ex:

a$= “Katahariya”

b$=  “Balirampur”

PRINT a$ + b$

The output will be KatahariyaBalirampur.

 

#Differentiate between view window and immediate window:

View Window

Immediate Window

1.     It is the largest oprtion of QBASIC editor screen.

1.It is the wide rectangular area just abive the reference bar.

2.     Program are usually written and stored in this mode.

2.It is useful to find out the instant result of QBASIC statement or command.

3.     Here, statements are stored in memory and then run by pressing Shift + F5 key.

3.Here, statements are written and executed diretly by pressing Enter key.

 

 

Sujit Prasad Kushwaha

A Dedicated Blogger Sharing Insights and Making a Difference.

Post a Comment

The comment section is your chance to make your mark. Don't hold back - add to the discussion and let your personality shine through!

Previous Post Next Post