100% found this document useful (1 vote)
1K views

Class 8 Qbasic Notes

QBASIC is a popular high-level programming language for beginners developed by Microsoft. It is easy to use and understand, making it popular among students. QBASIC supports numeric and string data types. Variables are used to store and change data values during program execution. QBASIC programs can perform calculations and display output using basic statements like PRINT, INPUT, IF-THEN-ELSE, and arithmetic, relational, and logical operators.

Uploaded by

Dipesh Dhami
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views

Class 8 Qbasic Notes

QBASIC is a popular high-level programming language for beginners developed by Microsoft. It is easy to use and understand, making it popular among students. QBASIC supports numeric and string data types. Variables are used to store and change data values during program execution. QBASIC programs can perform calculations and display output using basic statements like PRINT, INPUT, IF-THEN-ELSE, and arithmetic, relational, and logical operators.

Uploaded by

Dipesh Dhami
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Introduction to QBASIC String data: 

It consist of alphanumeric value i.e combination of letters and


numbers. For eg; “global” , “pokhara7”
QBASIC stands Quick Beginners All purpose Symbolic Instruction Code which is
a popular high level language for beginners developed by Microsoft corporation Variables: Those entities which holds either numeric or alphanumeric (string)
originally developed by Thomas Kurtz and John Kemeny. It is very easy to use values and changes its value throughout the time of program execution is
and understand so, It is popular among students. called variables. There are two types of variables.

Features of QBASIC

1. It use simple English like structure.

2. It has user friendly interface.

3. It automatically checks syntax error.

4. It has wide range keywords.

5. We can use both mouse and keyboard on its interface.

6. It capitalize keyword automatically.


Variables in QBASIC

Numeric variable: Those entities which holds only numeric values and changes
its value throughout the time of program execution is called numeric variables.

Eg, age = 17, i =2 , wardno = 12

String variable: Those entities which holds only alphanumeric values and


changes its value throughout the time of program execution is called string
variables.

Note: String variable should end with ‘$’ sign and its respective value should be
enclosed within double quotation “ “.

Example:  school$ = “global”, fname$ = “Krishna” ,  address$ = “Pokhara”

Rules while writing variables name:

1. Variable name should be 1 to 40 character long.


Software Breakdown  2. Blank space in variable name is not allowed.
Data types used in QBASIC For eg, ward no = 12 (Invalid) , wardno = 12(valid)
Numeric data: It consist of numeric values i.e. numbers 0-9 and its School name$ = “global” (Invalid)
combination. For eg; 45,12,1
Schoolname$ = “global” (Valid)
3. Any special symbol except $, #, !, %, & symbols are not allowed in variable    5+2 =7
name.
   5/2=2.5 (exact division)
Ward*no = 13 (Invalid) ,  ward$no = 14 (invalid)
   5\2 =2 (integer division)
4. Keyword cannot be used as a variable name.
   5 MOD 2 = 1 (Modulus division)
Print =3 (Invalid) 
   5^2 = 25
Cls =8 (Invalid)
Relational operator: It helps to compare different operands
Name =4 (invalid) if,else,while,for
>, <, >= , <= ,= , <> (not equal to)
5. Variable name should not start with number.
Logical operator: It helps to make logical comparison.
123abc = 2 (invalid), abc123 =2 (valid)
            AND, OR, NOT
123fname$ = “global” (invalid)
String operators: It helps to add two or more string. The process of adding two
fname123$ = “global” (valid) or more string is known as string concatenation. 

Constant: Those entities which holds either numeric or alphanumeric (string)  +


values and doesn’t changes its value throughout the time of program execution
C$ = a$+b$
is called constant. There are two types of constant.
QABSIC Expression
Numeric constant: Those entities which holds only numeric values and doesn’t
changes its value throughout the time of program execution is called numeric  a=r2. →→ a=r^2
constant.
 a=l.b →→ a =l*b
Eg, age = 17, i =2 , wardno = 12
 i =p*t*r100p*t*r100 →→i = (p*t*r)/100
String constant: Those entities which holds only alphanumeric values and
doesn’t changes its value throughout the time of program execution is called QBASIC statements and program
string constant. CLS (Clear Screen)
Note: String variable should end with ‘$’ sign and its respective value should be PRINT Statement: Display information on screen.
enclosed within double quotation “ “.
            Syntax:
Example:  school$ = “global”, fname$ = “Krishna” ,  address$ = “Pokhara”
            PRINT “Sample text”
Operators: The special sign or symbol that we use in our program to perform
some specific functions or operation are known as operators. Types of OR
operators:             age = 13
Arithmetic operators: It performs mathematical calculations             PRINT age
    + , - , * , / , \ , MOD, ^             PRINT “Age is =”;age
             v = pi*r^2*h

INPUT Statement: It helps to take input from the user. PRINT “Volume is”;v

Syntax: END

INPUT variable_name Q4) WAP to calculate average of three number. [Av=(a+b+c)/3]

INPUT “Any text”;VN CLS

Q1) Write a program to calculate area of rectangle. [A=l*b] INPUT “Enter first number”;a

CLS INPUT “Enter second number”;b

INPUT “Enter length”;l INPUT “Enter third number”;c

INPUT “Enter Breadth”;b av=(a+b+c)/3

A=l*b PRINT “Average is: ”;av

PRINT “Area is: ”;A END

END Q5) WAP to convert Nepali rupee into American dollar. [1$ = 118Rs]

Q2) WAP to calculate simple interest [i=(p*t*r)/100] CLS

CLS INPUT “Enter Nepali rupee”; N

INPUT “Enter principal”;p A = N/118

INPUT “Enter time”;t PRINT “America dollar”; A

INPUT “Enter rate”;r END

i=(p*t*r)/100 Q6) WAP to convert Celsius temperature into Fahrenheit. c−0100=f−32180c-


0100=f-32180
PRINT “Simple interest is: ”;i
18*c = 10*f-320
END
18*c+320 = 10*f
Q3) WAP to calculate volume of cylinder. [v=pr2h]
f = (18*c+320)/10
CLS
C = (10*f-320)/18
pi = (22/7)
CLS
INPUT “Enter radius”;r
INPUT “Enter Celsius”; c
INPUT “Enter height”;h
f = (18*c+320)/10
PRINT “Fahrenheit temperature”; f Syntax:

END IF (condition) THEN

IF Statement:  Block of statements no.1//

1. IF statement             ELSE

2. IF ELSE statement Block of statements no.2//

3. ELSEIF statement             END IF

1) IF statement Program example:

Syntax:  CLS

            IF (condition) THEN INPUT “Enter your age”; a

                        Block of statements// IF a>18 THEN

            END IF PRINT “You are eligible to vote”

Program example: ELSE

CLS PRINT “You are not eligible to vote”

INPUT “Enter your age”; a END IF

IF a>18 THEN END

PRINT “You are eligible to vote” CLS

END IF INPUT “Enter your percentage”; p

END IF p>=40 THEN

CLS PRINT “You are pass”

INPUT “Enter your percentage”; p ELSE

IF p>=40 THEN            PRINT “You are fail”

PRINT “You are pass” END IF

END IF END

END Q1) Write a program to input 2 different numbers and find the greatest
number.
2) IF ELSE statement
CLS
INPUT “Enter two number”; a,b PRINT n;”is not divisible by both 5 and 7”

IF a>b THEN END IF

           PRINT a; “is greatest” END

ELSE

           PRINT b; “is greatest”

END IF

END

Q2) Write a program to check whether the given number is odd or even.

CLS

INPUT “Enter a number” ; n

a = n MOD 2

IF a=0 THEN

PRINT n; ”is Even”

ELSE

PRINT n; ”is Odd”

END IF

END

Q3) Write to check whether the given number is exactly divisible by 5 and 7. 

CLS

INPUT “Enter a number” ; n

a = n MOD 5

b = n MOD 7

IF a=0 AND b=0 THEN

PRINT n;” is divisible by both 5 and 7”

ELSE

You might also like