100% found this document useful (1 vote)
1K views4 pages

Qbasic Notes For Class 7

Notes

Uploaded by

paularpita152
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views4 pages

Qbasic Notes For Class 7

Notes

Uploaded by

paularpita152
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

BASIC

BASIC (Beginners All Purpose Symbolic Instruct ion Code) is a very suitable high level
language for beginners. This language was developed in 1960 by Professors John Kemeny
and Thomas Kurtz. It is used in scientific, business and educational fields.

In the year 1975, Bill Gates and Paul Allen developed QBASIC (Quick Beginners All Purpose
Symbolic Instruct ion Code) language. It is a user- friendly language which enables various
kinds of tasks such as general programs, graphics etc. It is a compiler- based high level
language which perform s tasks in Window s environ ment.

Th e BASIC Charact er Set

Characters from the basic charact er set are combined to form keywords, variables,
operato rs and labels. These in turn combine to form instructions that make up a program.
The BASIC charact er set consists of:

• All alphabe tic letters, both uppercase and lowercase.


• All digits.
"" Some special charact ers.

The follow1ng charact ers have a special meaning to the BASIC translat or.

#, $ ➔ suffixes used at the end of variable names to specify the kind of variable .

+ I -I * / I ,
➔ Mathematical operato rs.
/"'\Ot:>
< ,> , = ➔ Relation al operato rs
'l -=- :> L-==- , L_'?
() ➔ Parentheses used

0
C,
·➔ Used while writing multiple stateme nts on a line.

• ➔ Used to separate output.


:Y
) ..:..) Used to separate input.

A -) Used for expone ntiation .

{ -)Used in place of PRINT stateme nt .



I -,, used to mark a line 35 a comme nt.

'"
• 7 l)ee~" rn~L 1)o~~t--
·BASIC datatypes

BASIC can handle both numeric and text data.

r Constants

BASIC constants are predefined values that do not change during program executi on . There
are two types of constants: String constants and Numeric constants.

Any string of characters between quotation marks is a string constant.

Eg :- "ABC", "abc4", "123"

Numeric constants are positive or negative numbers.

Eg: -124, 45, 34.12

Keywords

There are some words that have special significance to BASIC. These are called keywords.

Eg: PRINT, INPUT

Variables

A variable is a named memory location which holds a data value.

Variables are of two types :-

1. Numeric variable: A variable that contains a number.


~:- A=10 (Here A is a numeric variable)
2. Alphanumeric variable (String): A variable that contains group of alphabets or a single
alphabet or a group of numbers enclosed within double quotes (" ").
Ig:- A$="HELLO"
B$=" A"
11
C$= 1456"

Rules for writing variable names


Some rules must be followed foe writing the variable names.
• A variable name should start with an alphabet.
Eg:- AB1=12 (valid)
1AB=12 (invalid)
• A dollar sign($) must be used after the variable name in case of a string.
r
• w TG<h.s re.
"r rve_
._/.
t\=, (\OYl - CO\_ s.e Ser\.£ r l::
n rng a variable in lowercase does not affect the output.
• A variable canno t be assigned to a constant.
Eg:- a=S0 (valid)
S0=A (invalid)

PRINT statement

uses the PRINT statement to


A progr am is of no use unless it can outpu t a result. BASIC
This statement can be used
outpu t inform ation on the outpu t device, generally the monitor.
print a blank line.
to print data forma tted in differ ent ways. It can also be used to

E.g. :- PRINT" This is the mont h of July"


PRINT 7
er, more than one
• The PRINT state ment can be used to print more than one numb
(;) or a comma (,} is
string or a comb inatio n of both numbers and strings. A semicolon
used as a separator.
E.g.:-
PRINT 23; 30
PRINT "India " I· "New Delhi"
PRINT" July" , 2017, "Kolk ata"
where as a nurnb er is prince d
• String s are printe d witho ut any space s betwe en them,
ator.
with aspace befor e and after it, when semicolon is used as a separ
14 characters wide.
• BASIC divides the outpu t screen into 5 zones. Print zones are
is printe d in different
When a comma is used as a separator, the outpu t inform ation
zones.
• A blank line can be printe d using the PRINT statem ent itself.
E.g:- PRINT "HELLO"
PRINT
PRINT
PRINT "WORLD"
Output:
HELLO

WORLD
• More than one statement can be I d.
-
( :) · E.g. :- PRINT 20 : PRINT P ace in one I" .f h
ine I t ey are separated by a colon
30
• Generally PRINT statement takes th
the next PRINT t t e cursor to th e next line. Therefore the output of
s a ement will b h .
followed b . e on t e next line. But if the PRINT statement is
Ya semicolon or
a comma, the cursor stays on the same line.

PRINT "Hello"
PRINT "Hello"·
PRINT "World" '
PRINT "World"

Output: Output:
Hello \
HelloWorld
World \

I
INPUT Statement
The INPUT statement is used to provide input to the program while it is running.
E.g.:- INPUT name$
• It can be used to make the program more user friendly by providing a prompt or
message.
E.g.:- \NPUT" Enter your name:"; name$
INPUT" What is your age?"; a
#The string within the quotation marks after the INPUT statement is the prompt
telling the user what he/ she is required to input.

#A comma or a semicolon can separate the prompt and the variable that is to hold
the user input.
# a comma after the prompt suppresses the question mark.
# More than one value can be read with one INPUT statement.
E.g. :- INPUT "Enter two numbers:"; X,Y
PRINT "the first number is:" ;X
PRINT "the second number is:" ;Y

******************************* ***************************************

You might also like