about QBASIC programming
1.
What is QBASIC
programming language? Write its any two versions.
= Quick Beginner All
Purpose Symbolic Instruction Code (QBASIC) is one of the easy and popular high
level programming language developed by Microsoft Corporation USA. Its two
versions are: QBASIC 4.5 and QBASIC 6.4
2.
Write any four feature of
QBASIC.
-
QBASIC is interpreter
based language
-
QBASIC checks syntax
automatically
-
QBASIC supports modular
programming approach.
-
QBASIC is not case
sensitive
3.
What are the difference
between immediate window and view window?
Immediate
|
View
|
v The lower windows which is tiled as immediate is known as immediate
window.
|
v The upper window which is titled as 'Untitled'
window is known as view window
|
v It is the window to test command expression etc
|
v It is the window where we write program using QBASIC
language.
|
v To see the output of the statement we need to press Enter key
|
v To see the output of the statement we need to press
F5 key
|
4
.
What is meant by running
a program? Which key is used to run a program?
= Running ( Execution) is
the process by which a computer carries out the result or output of the
program.
We used F5 key to run a
program.
Elements of QBASIC programming Language
1.
What are the basic elements
required to develop the QBASIC program?
=The basic elements
required to develop the QBASIC program are:
a.
Character Set b. Keywords c. Variables d.
Constants e. operators f. Expression
2.
What is keyword? Give
some examples of QBASIC keywords.
= Keywords are the
collection of commands, statements or functions which are used to perform
specific task, also known as reserve words. Its examples are: INPUT, PRINT,
CLS, LET, REM etc.
3.
What is a variable? What
are the types of variables.
= A variable is a name of
storage location in computer's memory, in which we can store different values.
Its types are: a. Numeric Variable b.
String Variable
4.
What is a string
variable? Give some examples.
= A variable that store
string data ( alphanumeric data) that cannot be used for calculation is known
as string variable. For example: A$,
Ram$, Suman$
5.
Mention any four rules
for naming a variable.
=Four rules for naming a
variable are:
-
The variable name must
begin with alphabets.
-
The variable name may be
up to 40 character long.
-
The bank space is not
allowed in between the variable name.
-
Variable in QBASIC are
not case sensitive
6.
What is a constant? Write
its types.
=Constant are the fixed
values or notion which remain unchanged during the program execution time. Its
types are: a. Numeric constant b.
String constant
7.
What is string operator?
Write its example.
= The operator which is
used to combine or join two or more string value is called string operator. For
example:
string data (A$)
|
String data (B$)
|
Result (A$+B$)
|
"micro"
|
"soft"
|
Microsoft
|
"9845"
|
"4822"
|
98454822
|
8.
What is logical operator?
Write truth table of AND operator.
=The operator which is
used to combine two or more relational expression is called logical operators.
Truth table of AND operator:-
Condition (A)
|
Condition (B)
|
Result (A and B)
|
False
|
True
|
False
|
True
|
False
|
False
|
False
|
False
|
False
|
True
|
True
|
True
|
9.
List the types of numeric
variable with their declaration symbol.
=Types of numeric
variable with their declaration symbol are :
Types of Numeric Variable
|
Deceleration Symbol
|
Integer
|
%
|
Long Integer
|
&
|
Single Precision
|
!
|
Double Precision
|
#
|
QBASIC General Statements
1.
What is statement? List
any four QBASIC statements.
=A command or set of
instructions used in the program is called statement. Four QBASIC statements
are:
a.
LET statement b. INPUT statement c. PRINT statement d. REM statement
2.
What is the use of REM
statement in the program? Is it compulsory statement?
=The REM is a declaration
statement which is used to put comment or remark in the program. No it is not
compulsory statement.
3.
What is the different
between print with (;) and print with (,)?
=The semicolon (;) is
used with print statement to leave a single space between the items where as
comma (,) is used to leave 14 spaces (1 zone) between items.
4.
What is the use of
Read….Data statement?
= Read…..Data statement is used to read the
given value of data statement and store them with suitable variable.
Control Statements In QBASIC
1.
What are control
statements? Write two control statements.
= The statements which
alter and transfer the control flow from one statement line to another line are
called control statement. Two control statements are: a. IF……….THEN b.IF…….THEN……..ELSE
2.
What is looping? Write
the use of looping statement in QBASIC.
=Looping also known as
iteration is the process of repetition of some block of statements up to fixed
number of times. Looping statement are used in QBASIC to executed a block of
statements several times based on the specified condition.
3.
What are start value and
stop value of counter variable.
=Start value of counter
variable is the initial value of the counter and Stop value is the value that
the loop counter must pass to exit the loop; it marks the condition when the
loop should end.
4.
List any three looping
statements.
\=Three looping statements
are: a. FOR….NEXT b. WHILE……WEND c.
DO…..LOOP
5.
What is the difference
between IF…..THEN and IF…THEN….ELSE
statement?
= The IF…THEN statement
is the most simple form of the control statements which executed a block of
statements only if the specified expression is true where as IF…THEN…ELSE
statement is used to executed the multiple statements depending on the
condition.( When the condition is true, then the statement after then will be
executed and when the condition is false, the statements in the else block will
be executed.)
Program written by using
control statements
a.
To print the name of your
school for five times.
CLS
A$= "IRIS ENGLISH
ACADEMY"
FOR I= 1 TO 5
PRINT A$
NEXT I
END
b.
To print two different
numbers and check which one is smaller?
CLS
INPUT "Enter first
number"; A
INPUT "Enter second
number"; B
IF A< B THEN
PRINT "first number
is smaller than second"
END IF
IF B< A THEN
PRINT "second number is smaller than first"
PRINT "second number is smaller than first"
END IF
END
END
c.
To print the following
numeric series.
i.
2 4 8 16 32 64 upto
10th term.
CLS
A=2
A=2
FOR I=1 TO 10
PRINT A
A=A*2
NEXT I
END
ii.
3 33 333 3333 33333
CLS
A=3
FOR I= 1TO 5
PRINT A
A= A*10+3
NEXT I
END
iii.
5 55 555 5555
CLS
A=5
A=5
FOR I=1 TO 4
PRINT A
A=A*10+5
NEXT I
END
iv.
To display the first 10
integers for 1 to 10
CLS
FOR I= 1TO 10
PRINT I
NEXT I
END
NEXT I
END
v.
To display the Odd number from 1 to 10
CLS
FOR I= 1TO10 STEP 2
PRINT I
NEXT I
END
vi.
to display the series :
25 20 15 10 5
CLS
FOR I= 25 TO 5 STEP -5
PRINT I
NEXT I
END
vii.
To display the series: 4 16 35 64 100
CLS
FOR I=2 TO 10 STEP 2
PRINT I^2
NEXT I
END
viii.
To display the
multiplication table of an input number.
CLS
INPUT "Enter the
number"; N
FOR I= 1 TO 10
FOR I= 1 TO 10
PRINT N; "x";I;
"="; I*N
NEXT I
END
QBASIC programming by using general QBASIC Statement
a.
To calculate and display
the total price of 20 pencils if a pencil costs Rs 3.
CLS
LET P=3 p= price of single pencil
LET P=3 p= price of single pencil
LET TP= P*20 TP=
Total pencil price
PRINT "price of total Pencil";TP
END
b.
To enter radius of a
circle; then calculate and display its circumference.
CLS
INPUT "Radius of circle"; R
INPUT "Radius of circle"; R
LET C=2*22/7*R
PRINT "circumference"; C
END
END
c.
To enter length and
breadth of a room. Calculate and display its perimeter [P= 2(L+B)]
CLS
INPUT "Length of room"; L
INPUT "Length of room"; L
INPUT "Breadth of room"; B
LET P= 2*(L+B)
PRINT "perimeter of room"; P
END
d.
To input length in
centimeter and calculate its length in meter
CLS
INPUT " length in centimeter"; CM
INPUT " length in centimeter"; CM
LET M=CM/100
PRINT "length in
meter"; M
END
e. To input temperature in Celsius and calculate its temperature
in Fahrenheit. [ F=9/5*(c+32)]
CLS
INPUT "temperature
in Celsius"; C
LET F=9/5*(c+32)
PRINT "temperature
in Fahrenheit"; F
END
f. to input temperature in Fahrenheit and calculate its
temperature in Celsius . [ c=5/9*(f-32)]
CLS
INPUT "temperature
in Fahrenheit", F
LET C=5/9*(F-32)
PRINT "temperature
in Celsius"; C
END
g. A program that asks you to input money in nepali currency
and convert its value in dollar. [1$=90RS]
CLS
INPUT "nepali currency"; NC
INPUT "nepali currency"; NC
LET D= NC/90
PRINT "dollar";
D
END
h. A program that asks you to input a number ; that calculate the square and square root of that number.
CLS
INPUT
"number";N
LET S=N^2
LET S=N^2
LET SR=N^(1/2)
PRINT "square";
S
PRINT "square root";SR
PRINT "square root";SR
END
i. A program to find out simple interest
CLS
INPUT "Principal"; P
INPUT "Principal"; P
INPUT "Rate";R
INPUT "Time";T
LET SI=P*T*R/100
PRINT "Simple
Interest"; SI
END

Comments
Post a Comment