The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by myravu, 2020-05-22 09:15:41

New Gateway to Computer Science 8

New Gateway to Computer Science 8

Keywords: School Text Book

like Science, Mathematics, English, Computer and other subject is available by which
students can learn easily. The concept of distance learning is also based on multimedia.
Universities and colleges can provide multimedia CD and DVD to their students for the
learning as a studying material. Multimedia has the ability to accommodate different
learning styles by integrating text, picture, audio, video, etc.

Health

The flow of information related to health service can be exchanged with the help
of multimedia. It is mainly used to provide telemedicine services in the remote area.
Multimedia tools are also used to provide health services all over the world with the
help of video conference. Multimedia technology and devices are used to diagnosis the
diseases. Multimedia technology can be used to transform the information about the
health services and produce public awareness programs which can be broadcasts from
different media.

Entertainment

These days, without multimedia, entertainment is almost impossible. With the help of
multimedia, we can record music; create a video, movies and animated documents. 3D,
8D, 16D types of movies, digital movies, and animated cartoon films are possible because
of the use of multimedia.

Business

To create and promote business and products we can use multimedia. We can add
animation in the advertisement to make it more effective and interesting. For the
marketing strategy, the use of multimedia in business is essential.

Quick Learn

 Text, video, animation, audio, etc. are the elements of multimedia.
 Graphic is a visual multimedia element which represent such as a photo,
illustration, 3D or diagram.
 Animation is a visual technique that provides the illusion of motion by
displaying a collection of images in rapid sequence.
 The use of multimedia in education can make more changes in the teaching and
learning activities.
 Multimedia technology can be used to transform the information about health
services and produce public awareness programs in health sector.
 We can add animation in the advertisement to make it more effective and
interesting.
250 New Gateway to Computer Science Book-8

EXERCISE

1. Fill in the blanks with suitable words.

a. ……………… refers to interactive, computer-based applications that allow
people to communicate ideas and information with digital and print
elements.

b. A ………………………. file can be any computer file that plays audio and
video, audio only, or video only.

c. ………………Player is a media player and media library application
developed by Microsoft.

d. ………… is a visual multimedia element which represent photo, illustration,
3D or diagram.

e. The use of ……………………. in education can make more changes in the
teaching and learning activities.

f. ………………….. can be used to transform the information about the health
services and produce public awareness programs in health sector.

2. State whether the following statements are true or false.

a. Multimedia technology applies interactive computer elements, such as
graphics, text, video, sound, and animation to deliver a message.

b. Multimedia software is a software that is capable of playing or recording
audio files or playing or recording video files.

c. Text, video, animation, audio, etc. are the application of multimedia.

d. Audio is a visual technique that provides the illusion of motion by displaying
a collection of images in rapid sequence.

e. We can add animation in the advertisement to make it more effective and
interesting.

3. Write very short answer to the following questions.

a. Name any two elements of multimedia.

b. Write any two popular application areas of multimedia.

c. Is audio required in multimedia?

New Gateway to Computer Science Book-8 251

d. Write any one popular multimedia player software.
e. What method of teaching is effective in the classroom for learning process?
4. Write short answer to the following questions.
a. Define multimedia. What are the elements of multimedia?
b. What are the advantages and disadvantages of using multimedia?
c. What is a multimedia software? Name some popular multimedia software.
d. What are the components required for multimedia?
e. What are the application areas of multimedia? Explain one of them.
5. Write long answer to the following question.
a. Explain in details about the elements of multimedia.
b. What is the role of multimedia in education and entertainment? Explain in detail.

Lab Activities
• Divide your class in various groups and conduct a presentation on
the following topics.
• Application areas of multimedia.
• Role of multimedia in education.
• Latest multimedia technology for the entertainment.

252 New Gateway to Computer Science Book-8

Concept of Computer
Programming

Start Unit
Read a,b,c
5
No If a > c No
If a > b
Yes

No If b > c Yes Print a
Yes

Inside the UnitPrint c

Stop

Chapter 18 Program Designing Tools and Techniques
Chapter 19 Fundamental Knowledge of Programming
Chapter 20 Computer Programming in QBASIC

Elements of QBASIC statements

Practical Time
Specification Grid

Model Question

Chapter Program Designing Tools and Techniques

18

Expected Competency

At the end of thTihsiusnciht,aspttuedrecnotvsewrsilltbhee afoblleotwo:ing topics:
• identify the various program designing tools.
• write the features of algorithm.
• tell about the types of flow charts.
• define the pscudocode.

Introduction

Program Design tools are the tools used to develop a program. During designing a
program, different tools are required to solve several problems. Programming tool is a
computer program that software developers use to create, debug and maintain programs
and applications. The most basic tools are a source code editor and a compiler or interpreter,
which are used universally and continuously. A programming tool may be any software
program or utility that helps software developers or programmers in creating, editing,
debugging, maintaining and/or performing any programming or developing-specific task.
A programming tool is also known as a software development tool.

Tools for program designing

A programmer can use the given tools to design a program which we are going to discuss
below.

Algorithm

We have to use different steps to solve the problems. An algorithm is a set of instructions
designed to perform a specific task. We can define algorithm as a step by step procedure
to solve a given problem in a finite number of steps. The steps which we are writing
in algorithm should be in a proper sequential order. While preparing an algorithm, we
should identify what should be the input, process, output and storage.

254 New Gateway to Computer Science Book-8

Features of algorithm
 The entire algorithm should begin with ‘START’ and end with ‘STOP’ words.
 The words you are going to write for the algorithm should be clear and understandable.
 It helps to write and develop a program.
 Never use any programming code or language to write the algorithm.
 The final algorithm should produce actual result.

Some examples of algorithm

Write an algorithm to calculate simple interest.
Step 1 : Start
Step 2 : Input the principal amount and store it in variable P.
Step 3 : Input the time taken and store it in variable T.
Step 4 : Input the rate percentage and store it in variable R.
Step 5 : Calculate Interest with formula, interest = (PXTXR)/100
Step 6 : Display the value of interest
Step 7 :Stop

Write an algorithm to add two numbers entered by user.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum as sum = num1+num2
Step 5: Display sum
Step 6: Stop

Write an algorithm to find out the area of a room.
Step 1 : Start
Step 2 : Input the length of a room and store it in variable L.
Step 3 : Input the breadth of a room and store it in variable B
Step 5 : Calculate the area with formula, Area = (LXB)/100
Step 6 : Display the area of room.
Step 7 :Stop

New Gateway to Computer Science Book-8 255

Flowchart

Flowcharts use special shapes or symbols representing different types of actions or
steps in a programming process. It is a diagrammatically representation of an algorithm.
Flowcharts are commonly used in developing business plans, designing algorithms and
determining troubleshooting steps. Many software programs are available to design
flowcharts. Some of the commonly used software programs are Smart Draw and Visio.
Flowcharts are useful to:
 collect data about a particular process.
 understand the relationship among different process steps.
 help in decision making.
 show the structure of a process.
 measure the performance of a process.
 highlight important steps and eliminate the unnecessary steps.
 track the process flow.
Rules for drawing flowcharts.
 Never forget to use start and ending symbols at the beginning and ending of
flowchart.
 Do not forget to analyse the input, process, storage and output.
 There should be list of activities inside each symbol.
 Do not cross the flow lines with each other symbols.
 It should express all sections like input, process, logical and output.
 It should not be any programming language oriented.
 Always use connector if a flowchart is not sufficient in a page.

Quick Learn

 Program Design tools are the tools used to develop a program.
 Programming tool is a computer program that software developers use to create,
debug and maintain programs and applications.
 A programming tool is also known as a software development tool.
 Algorithm is a step by step procedure to solve a given problem in a finite number
of steps.
 Flowchart is a diagrammatically representation of an algorithm.

256 New Gateway to Computer Science Book-8

Types of flow chart

There are two types of flowcharts which are explained below.

System flowchart

System flowcharts are a way of displaying how data flows in a system and how decisions
are made to control events. This is the most common type of flowchart. It is used to show
the logical flow of the process and includes decisions, flows of control, data stores and
documents.

Program flowchart

Program flowchart is a diagram which uses a set of standard graphic symbols to represent
the sequence of coded instructions fed into a computer, enabling it to perform specified
logical and arithmetical operations. It is a tool to improve work efficiency. There are
four basic symbols in program flowchart; start, process, decision and end. Each symbol
represents a piece of the code written for the program.

S.N Symbols name Description
1. Start / Stop It indicates the starting and ending of
flowcharts.
2. Input / Output
It indicates input or output
3. Processing operations.
4. Decisions
It indicates any calculations or ma-
nipulations.
It is used to show the steps involving
comparison and decision
making.

5. Flow lines It shows the flow of control in a pro-
gram.

6. Connectors It indicates a junction point at which
7. Comment flowchart joins with a part of flow-
New Gateway to Computer Science Book-8 chart to another place or part.

It is used to write the comments about
flowchart symbol.

257

Some examples of flowcharts
Draw a flowchart to find out the sum of any two numbers.

Draw

Read A
Read B
Sum=A+B

Print Sum

End

Draw a flowchart for finding the smallest of three numbers.
Start

Read a,b,c

No If a > b No If a > c No
Print b Yes Yes Print a
smallest
If b > c Stop
Yes

Print c

258 New Gateway to Computer Science Book-8

Pseudocode

Pseudocode is a simple way of writing programming code in English. Pseudocode is not
actual programming language. So, it cannot be compiled into an executable program. It
uses short terms or simple English language syntaxes to write code for programs before
it is actually converted into a specific programming language. This is done to identify top
level flow errors and understand the programming data flows that the final program is
going to use.

Examples of Pseudocode

Write a pseudocode to add 2 numbers together and then display the result.
Start Program
Enter two numbers, A, B
Add the numbers together = A + B
Display the Sum
End Program
Write a pseudocode to calculate the area of a rectangle.
Start Program
Get the length, l, and width, w
Compute the area = l*w
Display the area
End Program

Quick Learn

 There are two types of flowchart. They are program flowchart and system
flowchart.
 System flowcharts are the way of displaying how data flows in a system and how
decisions are made to control events.
 Program flowchart is a diagram which uses a set of standard graphic symbols to
represent a sequence of coded instructions.
 There are four basic symbols in program flowchart. They are start, process,
decision and end.
 Pseudocode is a simple way of writing programming code in English.
 Pseudocode is not a programming language.

New Gateway to Computer Science Book-8 259

EXERCISE

1. Fill in the blanks with suitable words.
a. Program ………. are the tools used to develop a program.

b. A …………….. tool is also known as a software development tool.

c. ……………. is a diagrammatically representation of an algorithm.

d. There are two types of flowchart. They are program flowchart and ……………
flowchart.

e. ………………… is a diagram which uses a set of standard graphic symbols to
represent the sequence of coded instructions.

f. …………….. is not a programming language.

2. State whether the following statements are true or false.
a. Programming tool is a computer program that software developers use to create,
debug and maintain programs and applications.
b. Flowchart is a step by step procedure to solve a given problem in a finite number
of steps.
c. System flowcharts are the way of displaying how data flows in a system and how
decisions are made to control events.
d. Pseudocode is a simple way of writing programming code in English.
e. There are three basic symbols in program flowchart they are start, process, decision
and end.

3. Write very short answer to the following questions.
a. What is the use of program design tools?
b. Write the name of any two programming languages that you know.
c. What is another name for the programming tool?
d. Name any two types of flowcharts.
e. Name any two shapes that are used in flowchart.

f. Does an algorithm use symbols in steps?

260 New Gateway to Computer Science Book-8

4. Write short answer to the following questions.
a. Define algorithm and flowchart.
b. Write down the features of an algorithm.
c. What are the uses of flowchart?
d. Draw various symbols used by flowchart.
e. What is a pseudocode? Write a pseudocode to calculate the area of rectangle.
5. Write long answer to the following questions.
a. Explain the rules for drawing flowchart. What are the types of flowchart? Explain
them.
b. Draw a flowchart to calculate the simple interest and amount.
c. Draw a flowchart to find the area of a triangle.

Project Work & Activity

• Prepare a chart with the symbols used by flowchart and submit to your teacher.

New Gateway to Computer Science Book-8 261

Chapter Fundamental Knowledge of
Computer Programming
19

Expected Competency

At the end of thTihsiusnciht,aspttuedrecnotvsewrsillthbeefaoblleowtoi:ng topics:
• define computer language with its types.
• explain the advantages and disadvantages of programming langauages.

Introduction

Today, most people do not need to know how a computer works. Most people can simply
turn on a computer or a mobile phone and point at some little graphical object on the
display, click a button or swipe a finger or both, and the computer does something. But,
since we are going to learn how to write computer programs, you need to know about how
a computer works. Basically, writing software (computer programs) involves describing
processes, procedures; it involves the authoring of algorithms about which we learnt little
in previous classes.

A computer does not understand any languages as human. Programming language is
needed to write a computer program. It is an artificial language that is used to communicate
between computer hardware and user. We can use the three different languages to write
the computer programs. They are machine language, assembly language and high level
language. Among the three languages these days we are using high level languages to
write the computer programs.

Types of computer language

Machine level language

This language can be understood by the computer only. It is also called as the first
generation language. Writing program in this language is very difficult because these are
closer to machine but not a user. Machine level language is sometimes called a machine
code or object code. It is a collection of binary digits or bits that the computer reads and
interprets.

262 New Gateway to Computer Science Book-8

Advantages of machine language
 It can be directly understood by the machine.
 Program of machine language runs very fast
 Translation program is not required for the CPU.
 It uses less memory so it can be used in each type of machine.
Disadvantages of machine language
 It is very difficult to program in machine language.
 The programmer has to know details of hardware to write program.
 The programmer has to remember a lot of codes to write a program
 It is difficult to debug the program.

Assembly Language

It is a low-level programming language used to interface with computer hardware.
Assembly language uses structured commands as replacements for numbers. Only
assembler can be used to translate the assembly language into machine level language
and vice versa. An assembly language is the most basic programming language available
for any processor. With assembly language, a programmer works only with operations
that are implemented directly on the physical CPU. Assembly languages have the same
structure and set of commands as machine languages, but they enable a programmer to
use names instead of numbers.

Advantages of Assembly Language
 Memory efficient.
 Programs written in machine language are replaceable by mnemonics which are easier
to remember.
 Faster in speed.
 Easy to make insertions and deletions.
 Requires fewer instructions to accomplish the same result.

Disadvantages of Assembly Language
 Long programs written in such languages cannot be executed on small sized
computers.
 It takes lots of time to code or write the program.
 It is more complex in nature.
 Difficult to remember the syntax.
 Lack of portability of program between the computers.

New Gateway to Computer Science Book-8 263

High Level language

High level languages are closer to human language. A machine cannot understand any type
of high level language. A translator like compiler and interpreter can be used to translate
the language from high level language to machine level language and vice versa. The
programming style and context is easier to learn and implement in high level language
than low-level languages. BASIC, PASCAL, FORTRAN, C/C++, HTML, JAVA, etc. are
the examples of high level language.

Advantages of high level language
 High level languages are closer to human language.
 It is very easy to understand.
 It does not depend upon a machine.
 It is very easy to modify.

Disadvantages of high level language
 It cannot be understood by the machine.
 It does not execute directly on the computer system.
 Language translator is essential to convert the high level language into machine
code.
 More memory is needed to work with programs.

Quick Learn

 A computer does not understand any languages as human.
 Programming language is needed to write a computer program.
 We can use the three different languages to write the computer programs
they are machine language, assembly language and high level language.
 Machine level language can be understood by the machine only.
 Machine level language also called as machine code or object code.
 Assembly Language is a low-level programming language used to interface
with computer hardware.
 Assembly languages have the same structure and set of commands as machine
languages, but they enable a programmer to use names instead of numbers.
 High level languages are closer to human language.
 A translator like compiler and interpreter can be used to translate the language
from high level language to machine level language and vice versa.
 BASIC, PASCAL, FORTRAN, C/C++, HTML, JAVA, etc. are the examples of
high level language.

264 New Gateway to Computer Science Book-8

EXERCISE

1. Fill in the blanks with suitable words.
a. ……………….. is needed to write a computer program.
b. …………………. level language can be understood by the machine only.
c. ……………language is a low-level programming language used to interface with
computer hardware.
d. High level languages are closer to ……………… language.
e. BASIC, PASCAL, FORTRAN, C/C++, HTML, JAVA, etc. are the examples of
………...
2. State whether the following statements are true or false.
a. A computer does not understand any languages as human.
b. Machine language, assembly language and high level language are the
three types of programming language.
c. Machine level language is also called as machine code or object code.
d. Machine languages have the same structure and set of commands as machine
languages, but they enable a programmer to use names instead of numbers.
e. A translator like compiler and interpreter can be used to translate the language
from high level language to machine level language and vice versa.
3. Write very short answer to the following questions.
a. What is the name of language that can be understood by the machine only?
b. Name any two high level languages.
c. Name the high level language that you know.
d. Is assembly language a high level language?
e. Which of the computer language is also called object code?

New Gateway to Computer Science Book-8 265

4 Write short answer to the following questions.
a. What is a programming language? Write down the types of computer languages.
b. What are the advantages and disadvantages of machine languages?
c. What is an assembly language? Write its advantages and disadvantages.
d. Define high level language with its examples.
e. Mention the advantages and disadvantages of high level languages.
5. Write long answer to the following question.
a. Explain the role of programming language in computer system.

Project Work & Activity

• Make a list of any 10 programming language in A4 paper with the help of the
internet and submit to your teacher.



266 New Gateway to Computer Science Book-8

Chapter Computer Programming in
QBASIC
20

Expected Competency

At the end of thTihsiusnciht,aspttuedrecnotvsewrsillthbeefaoblleowtoi:ng topics:
• define QBASIC with its features.
• tell the elements of QBASIC.
• identify the types of operators.
• explain various QUBASIC statements.
• describe QUBASIC looping structure.

Introduction

QBASIC stands for Quick Beginners All-purpose Symbolic Instruction Code. It is the
most popular high level programming language. QBASIC is the advanced form of BASIC
program. The BASIC program was developed by John George Kemeny and Thomas
Eugene in 1964 AD in USA. This language is quite simple to understand and has been
adopted by most of the microcomputers.

Features of QBASIC

 It is very easy to understanding and writing the programs.
 It has menu so that we can use QBAIC menu to perform various tasks easily.
 It is very easy to debug the programs.
 It is used for both scientific and commercial applications.

Starting QBASIC

 Boot your computer system.
 Open the QBASIC folder location.

New Gateway to Computer Science Book-8 267

 Double click on exe file of QBASIC.
 Now, you can see the QBASIC screen as below.

 Press Esc key to remove the welcome dialogue box and start working on QBASIC.

Elements of QBASIC programming

Character Set
A set of characters that are allowed to use in QBASIC is known as the QBASIC Character
Set. The QBASIC Character Set consists of alphabets (both small and capital), numbers
(0 to 9) and special characters. These special characters have their own meaning and
functions. QBASIC has the character set consisting of the following elements:
 Alphabets: A, B, C,....Z
 Digits: 0, 1, 2........,9 and
 Special characters: + - * / ( ) . , $ ; ,: ,= ,> ,< , ^ etc.
Variables
To store data in the computer, location are used. To locate or naming the address variables
are used. Variable is a symbolic name that is used to store data (numbers, text, string,
special characters, etc.) in the computer memory. During the program execution, the
value of a variable is assigned to the computer memory. The following are the types of
variables.
 Numeric Variable
 String Variable

268 New Gateway to Computer Science Book-8

Numeric Variable

Numeric Variable is a symbolic name which is used to store only the numeric data. To
declare numeric variable, the characters A-Z, a-z, string, special characters are used. For
example

x=20

Salary = 25000

a=5

Age = 12

A=13.5

B=25

SUM=A+B

Types of Numeric variables

Types of variable The number/character that it can hold Example
Integer
Long Integer A whole number between -32,768 and 32,767 A%

Single precision A whole number between -2,147,483,648 and A&
Double precision
String +2,147,483,648

Number from -3.37X10^38 to 3.37 X 10^38 A!

Number from -1.67X10^308 to 1.67X10^308 A#

O to 32,767characters A$

String Variable

String Variable is a symbolic name which is used to store text, text with numbers. $ sign
is used at the end of string variable. The value of the string variable is stored in double
quotation marks “ “. The following are the example to store string variable.

N$ = “I am Dinesh Adhikari.”

A$ = “I am from Dhading.”

In the above example, N$, A$ are the string variables which store the value “I am Dinesh
Adhikari.” and “I am from Dhading.”

Rules for writing the variable name
 Variable name can be up to 40 characters.
 Do not use space between the names of variables.
 The name of variable always starts from alphabet and can follow by numbers.
 Never use QBASIC reserved words as a name of variables like CLS, INPUT,
CLS, PRINT, etc.

New Gateway to Computer Science Book-8 269

Constants

Constant is an identifier whose value does not change during the program execution.
The value of constant is fixed value which is used in the program. There are two types of
constants that we are going to discuss below.
 Numeric Constants.
 String Constants.

Numeric Constants

Numeric constant consists of a sequence of digits with or without decimal value. Numeric
constant is a numeric value which is used in program. In numeric constant comma and
blank space are not allowed to use. Let’s see an example.
ADD = 20 + 10
In the above example, 20 and 10 are the numeric constants.
String Constants:
String constant is a string value which is used in program. In other words, it is the collection
of numbers or texts or text with numbers followed by the $ sign. In string constant, we can
use comma and blank spaces. Let’s see an example.
D$=”Pravash”
A$=”NeelakanthaDhading”

Quick Learn

 QBASIC is the most popular high level programming language.

 QBASIC was developed by John George Kemeny and Thomas Eugene in

1964 AD in USA.

 The elements of QBASIC programming are character set, variables, constants,

etc.

 A set of characters that are allowed to use in QBASIC is known as the QBASIC

Character Set.

 The QBASIC Character Set consists of alphabets, numbers and some special

characters.

 Variable is a symbolic name that is used to store data in the computer’s memory.

 Numeric and string are the two types of variables.

 The value of constant is fixed which is used in the program.

 Numeric constant consists of a sequence of digits with or without decimal value.

 String constant is a string value which is used in program

270 New Gateway to Computer Science Book-8

Operators and Operands
Operators are the sign or symbols that are used to do mathematical calculations like
addition, subtraction, multiplication and division. There are four types of operators in
QBASIC. They are Arithmetic Operators, Relational Operators, Logical Operators and
String Operator.

Operands are the variables or constant values on which the operation is done. For example
in expression [a + b], + is operator and ‘a’ and ‘b’ are operand. The whole expression
[a + b] is called as the operations.

Types of operators

Arithmetic Operators

Arithmetic Operators are used to perform mathematical calculations like addition,
subtraction, division, multiplication and exponential. The following table shows arithmetic
operators used in QBASIC.

Operation Operator Examples Output
Addition + 20 + 30 50
Subtraction - 45-10 35
Multiplication * 6*10 60
Floating-point Division / 10/2 5
Integer Division \ 13\2 6
Modular Division MOD 15 MOD 7 1
Exponential ^ 3^3 27

Relational Operators

Relational Operators are used to compare the value of variables. A comparison of string
data with numeric data cannot be done. The comparison of string data is done on the basis
of ASCII value. The result of comparison is either true (1) or false (0).The following table
shows the relational operators used in QBASIC.

Relation Operator (Sign) Examples
Equal to = A=B
Greater than > A>B
Less than < A<B
Greater than or equal to >= A>=B
Less than or equal to <= A<=B
Not equal to <> A<> B

New Gateway to Computer Science Book-8 271

Logical Operators

Logical Operators combine two or more relational expressions to evaluate a single value
as True or False. The result of evaluation is used to make decisions about the program
flow. The AND, OR and NOT are the commonly used logical operators.

AND Operator

AND operator returns ‘True’ when all the results returned from individual relational
expressions are ‘True’. Otherwise it returns, ‘False’. The AND Truth Table is given below.

Truth Table for AND operator

INPUT (A) INPUT (B) Output (A and B)
T F F
T T T
F F F
F T F

OR Operator:

OR Operator returns ‘True’ if one of the relational expressions returns ‘True’. If all the
relational expressions returns ‘False’, then only the result will be ‘False’.

Truth Table for OR operator

INPUT (A) INPUT (B) Output (A OR B)
T F T
T T T
F F F
F T T

NOT Operator:

NOT Operator operates on one operand and returns ‘True’ if the logical operation returns
‘False’. The NOT truth table is as given below.

Truth Table for NOT operator

INPUT (A) Output (NOT A)
T F
F T

272 New Gateway to Computer Science Book-8

Expression

An expression can be a string, or numeric constant, a variable or a combination of
constants, variables with operators which return a single value. We can write algebraic
expression in QBASIC expression as given below.

Algebraic Expression QBASIC expression
3(AB + BC) 3*(A*B + B*C)
ab (a*b) / (b*c)
bc
A2 + B2 A^2 + B^2
A = 2h (L+B) A = 2*h *(L+B)

Statements

A statement is a computer instruction written in a source language, such as QBASIC,
which is converted into one or more machine code instructions by a compiler. The
commonly used QBASIC statements are: LET, PRINT, INPUT, CLS, END and REM in
QBASIC which are described below.

Quick Learn

 There are two types of flowcharts. They are program flowchart and system
flowchart.

 Operators are the sign or symbols that are used to do mathematical
calculations like addition, subtraction, multiplication and division.
 Logical Operators combine two or more relational expressions to evaluate
a single value as True or False.
 An expression can be a string, or numeric constant, a variable or a
combination of constants, variables with operators which return a single
value.
 A statement is a computer instruction written in a source language, such as
QBASIC, which is converted into one or more machine code instructions
by a compiler.

New Gateway to Computer Science Book-8 273

Types of QBASIC Statements

LET statement

LET is an assignment statement. It is used to assign the value to a variable. LET is an
optional statement i.e. without using LET statement we can assign the value to a variable.
The data type must match with the variable type otherwise type mismatch error will
occur.

Syntax: LET <variable>= <value or expression>

Practical Time
CLS
LET A= 20
LET B = 30
LET SUM = A+B
PRINT “The Sum is”; SUM
END
CLS statement
This command is used to clear the previous output screen. If you write CLS statement in
the middle of the program, then you cannot see the outputs generated before execution of
CLS because it clears the screen.
Syntax: CLS

REM statement
REM statement is a non-executable statement and stands for remarks. It is a basic
declaration statement that allows explanatory remarks to be inserted in a program. The
remarks may be useful in a program to explain about different kinds of statements and
user defined words.
Syntax: REM <text for remarks>

PRINT statement

PRINT command is used to display any message or value on the screen. PRINT statement
provides output on the screen. It prints the values of the expression on the screen. If

274 New Gateway to Computer Science Book-8

the expression list is blank, no characters are printed. The expressions in the list may
be numeric or string. We can use semicolon and comma with a print statement which
results differently than a normal PRINT statement. If expression list ends with comma or
semicolon, the next PRINT statement prints on the same line. Comma provides a TAB
space, but semicolon provides only one space.

Syntax : PRINT [“Message”]; expression

Practical Time

A program to display the text or number on the screen.

CLS

PRINT “We are learning QBASIC programming.”

PRINT

PRINT “Learning QBASIC is fun.” Output
PRINT 98511 We are learning QBASIC programming
PRINT “The number is:” ; 22004
END Learning QBASIC is fun 98511
The number is: 22004

INPUT statement

INPUT statement in QBASIC is used to accept the data item from the user. It allows
entering values into the computer’s memory during the program execution. This statement
will print and wait for the user to enter the value and then assign this value to a variable.

Syntax : INPUT [“Message”]; Variables

Practical Time

A program to find out the sum of any three numbers.

CLS Output
INPUT “Enter the first number: ”; A Enter the first number: 20
INPUT “Enter the second number: ”; B Enter the second number: 30
INPUT “Enter the third number: ”; C Enter the third number: 40
SUM = A + B + C The sum of the three number is :90

PRINT “The sum of the three number is : ”; SUM

END

New Gateway to Computer Science Book-8 275

END statement
END statement is used to terminate or quit from the QBASIC program. It can be used
only one time in one program.
Syntax: END

Selection Structure

It is also known as branching structure that allows you to transfer the program control
from one part to another on the basis of specified condition or without condition. Here,
we are going to learn some selection structures in QBASIC.

IF......THEN Statement

It helps the computer to check whether the relation is TRUE or FALSE. This statement is
used to make the decision as well as comparison.

Syntax

IF <condition> THEN

(statement)

END IF

Practical Time

A program to check whether the entered number 10 is greater than 2 or not.

CLS

INPUT A , B Output
IF A> B THEN 10 is greater than 2.
PRINT A; "is greater than 2."

END IF

END

Practical Time

A program to check whether the entered number is divisible by 2 or not.

CLS Output
N = 10 it is divisible by 2.
IF N MOD 5 = 0 THEN

PRINT “it is divisible by 2.”

END

276 New Gateway to Computer Science Book-8

IF......THEN……..ELSE Statement

It is the two way decision making statement that can decide which part of statement it
has executed when the condition is true or false. It executes one part of a program if the
condition is true and another part if the condition is not true or false.

Syntax:

IF <condition> THEN

(statement 1)

ELSE

(statement 2)

END IF

Practical Time
A program to check whether the entered number is odd or even.
CLS
INPUT “Enter the number” ; N
R = N MOD 2
IF R = 0 THEN
PRINT “It is an even number”
ELSE
PRINT “It is odd number”
END IF
END
Practical Time
A program to check whether the number is divisible by 4 and 6 or not.
CLS
INPUT “Enter the number” ; N
IF N MOD 4 = 0 and N MOD 6 = 0 THEN
PRINT “The number is divisible by 4 and 6”
ELSE
PRINT “The number is not divisible by 4 and 6”
END IF
END

New Gateway to Computer Science Book-8 277

If.....Then....Else If......Else statement
It is multi-way decision making statement that is used when there is two or more conditions
to be evaluated.
Syntax:
IF <condition 1> THEN
(statement 1)
ELSE IF <condition 2> THEN
(statement 2)
……………………
……………………
ELSE
(statement N) [N = any number]
END IF

Practical Time
A program to print the greatest number among three different numbers.
CLS
INPUT “Enter first number”; A
INPUT “Enter second number”; B
INPUT “Enter third number”; C
IF A>B AND A>C THEN
PRINT A; “is greater”
ELSEIF B>A AND B>C THEN
PRINT C; “is greater”
ELSE
PRINT C; “is greater”
END IF
END

278 New Gateway to Computer Science Book-8

Quick Learn

 LET is an assignment statement which is used to assign the value to a variable.
 CLS command is used to clear the previous output screen.
 PRINT command is used to display any message or value on the screen.
 INPUT statement in QBASIC is used to accept the data item from the user.
 END statement is used to terminate or quit from the QBASIC program.
 Selection structure is also known as branching structure that allows you to
transfer the program control from one part to another.
 IF......THEN statement helps the computer to check whether the relation is TRUE
or FALSE.
 IF......THEN……..ELSE statement is the two way decision making statement
that can decide which part of statement it has executed when the condition is
true or false.
 If.....Then....Else If......Else statement is multi-way decision making statement
that is used when there are two or more conditions to be evaluated.

QBASIC looping Structure

A looping structure is a logic which is used to execute one or more than one statements
for a number of times. A loop allows a group of statements to be executed a certain
number of times depending upon the condition. Here we are going to discuss some
looping structures.

For........Next Statement

It repeats a block of statement for specified number of times. It is used to execute a series
of instructions for a given number of times.

Syntax:

FOR <control variable> = <initial value> TO <ending value> STEP <N>

(Statement block)

NEXT < control variable>

New Gateway to Computer Science Book-8 279

Practical Time
A program to display the number from 1 to 50.
CLS
FOR I = 1 TO 50
PRINT I;
NEXT I
END

Practical Time

A program to display the number such as 1, 3 , 5 , 7 , 9
CLS
FOR I = 1 TO10 STEP 2
PRINT I;
NEXT I
END

While.....Wend Statement
It executes a block of statements repeatedly till the specific condition is true. When the
value of the condition is false, the loop stops.
Syntax:
WHILE <condition>
(statement)
(Increase / decrease the value of control variable)
WEND

Practical Time
A program to display the number such as 1,4 ,7 , 10………….25.
CLS
A=1
WHILE A<=25
PRINT A
A=A+3
WEND
END

280 New Gateway to Computer Science Book-8

Do....Loop Statement
It repeats a part of program while a condition is true or until the condition becomes
true. This statement repeats block of statements while the condition is true or until the
condition becomes true.
Syntax 1
DO WHILE <condition>
(statement)
LOOP
Syntax 2
DO
(statement block)
LOOP WHILE <condition>

Quick Learn

 A looping structure is a logic which is used to execute one or more than one
statements for a number of times.
 For........Next statement repeats a block of statement for specified number of
times.
 While.....Wend statement executes a block of statements repeatedly till the specific
condition is true.
 Do....Loop statement repeats a part of program while a condition is true or until the
condition becomes true.

EXERCISE

1. Fill in the blanks with suitable words.
a. A set of characters that are allowed to use in QBASIC is known as ………
b. ………….. is a symbolic name that is used to store data in the computer’s
memory.
c. The value of …………… is fixed which is used in the program.
d. …………….. command is used to clear the previous output screen.
e. ……… statement in QBASIC is used to accept the data item from the user.


New Gateway to Computer Science Book-8 281

f. Selection structure is also known …………….. that allows you to transfer
the program control from one part to another.

g. IF-THEN-ELSE statement is the two way …………… statement that can decide
which part of statement it has executed when the condition is true or false.

h. A ……………….. is a logic which is used to execute one or more than one
statements for a number of times.

i. …………statement repeats a block of statement for specified number of times.

j. While-Wend statement executes a block of statements repeatedly till the
specific condition is ………………..

2. State whether the following statements are true or false.

a. QBASIC is the most popular low level programming language.

b. The elements of QBASIC programming are character set, variables, constants,
etc.

c. The QBASIC variable consists of alphabets, numbers and some special
characters.

d. Numeric and string are the two types of variables.

e. String constant consists of a sequence of digits with or without decimal value.

f. Numeric constant is a string value which is used in program.

g. Logical Operators combine two or more relational expressions to evaluate a single
value as True or False.

h. CLS is an assignment statement which is used to assign the value to a variable.

i. PRINT command is used to display any message or value on the screen.

j. IF-THEN statement helps the computer to check whether the relation is
TRUE or FALSE.

3. Write down the function to the following QBASIC statements.

REM , INPUT, END , LET, IF…..THEN, FOR….NEXT,

WHILE……WEND, DO….LOOP

4. Write very short answer of the following questions.

a. What are the character set used by QBASIC?

b. Write a suitable example for string variable.

c. Name two arithmetic operators.

d. What are the types of logical operators?

e. Which statement is used to clear the output screen?

282 New Gateway to Computer Science Book-8

f. Name any one selection structure of QBASIC.

g. Name the looping structure that you know.

5. Write short answer to the following questions.
a. What is QBASIC? Write its features.
b. What are the elements of QBASIC programming?
c. Define variable and constant.
d. What are the types of variables? Explain them in short.
e. What is an operator? Name the types of operators.
f. What are statements? List out the name of statements.
g. What is a selection structure? Write some selection structure.
h. What is a looping structure? Write some looping structure.
6. Write long answer to the following questions.
a. Explain the types of operators with its truth table.
b. Explain the types of operators with examples.
7. Write QBASIC program for the following.
a. To find out the smallest number among the four different given numbers.
b. To display the natural number from 1 to 100.
c. To display the add numbers from 1 to 50.
d. To print the factors of a given number.
e. To calculate the cube root of a given number.

Lab Activities
• Perform the following activities in your computer lab and note
down the output.
a. To find out the smallest number among the four different given
numbers.
b. To display the natural number from 1 to 100.
c. To display the add numbers from 1 to 50.
d. To print the factors of a given number.
e. To calculate the cube root of a given number.

New Gateway to Computer Science Book-8 283

Practical Time-1

A program to display the number such as 100, 90, 80, 70, 60………up to 10.
CLS
N = 100
DO
PRINT N;
N = N – 10
LOOP WHILE N> = 10
END
Write a program to calculate the sum of the first ten natural numbers.
CLS
I=1
SUM = 0
WHILE I <=10
SUM = SUM + I
I=I+1
WEND
PRINT SUM
END

Practical Time-2

Write a QBASIC program to find out the average of any two numbers.
CLS
INPUT “Enter the first number”; A
INPUT “Enter the second number”; B
AVG = (A+B)/2
PRINT “The average value is”; AVG
END

284 New Gateway to Computer Science Book-8

Practical Time-3

Write a QBASIC program to find out the area of a circle.
CLS
INPUT “Enter the radius of a circle”; R
A = 3.14*R*R
PRINT “The area of a circle is”; A
END

Practical Time-4

Write a QBASIC program to convert the kilometre into meter.
CLS
INPUT “Enter the kilometre value ”; K
M = K * 1000
PRINT “The distance in meter is::”; M
END

Practical Time-5

Write a QBASIC program to print the factors of a given number.
CLS
INPUT “Enter any number”; N
FOR I = 1 TO N
IF N MOD I = 0 THEN
PRINT I
NEXT I
END

New Gateway to Computer Science Book-8 285

Practical Time-6
Write a QBASIC program to print the greatest number among ten different numbers
CLS
INPUT “Enter the first number”; A
FOR I = 2 TO 10
INPUT “Enter the next number”; B
IF B>A THEN A = B
NEXT
PRINT A; ” is the greatest number”
END

Practical Time-7
Write a QBASIC program to calculate the cube root of a given number
CLS
INPUT “Enter any number”; N
A = N ^ (1 / 3)
PRINT “Cube root of “; N; ” is “; A
END

Practical Time-8
Write a QBASIC program to calculate the area of circle.
CLS
INPUT “ENTER THE RADIUS OF CIRCLE”; R
A = 3.141*R^2
PRINT “AREA OF CIRCLE =”; A
END

286 New Gateway to Computer Science Book-8

Practical Time-9

Write a QBASIC program to generate number series. 3,6,9...up to 15 terms.
CLS
N=15
FOR I = 3 TO N STEP 3
NEXT I
PRINT I
END

Practical Time-10

Write a QBASIC program to display the series 1,2,4,7,11upto 15th term.
CLS
A=1
FOR I=1 TO 15
PRINT A;
A=A + I
NEXT
END

Practical Time-11

Write a QBASIC program to enter any two numbers and display the smaller one.
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
IF A < B THEN
PRINT A; “IS SMALLER”
ELSE
PRINT B; “IS SMALLER”
END IF
END

New Gateway to Computer Science Book-8 287

Practical Time-12

Write a QBASIC program to enter any 10 numbers and display the greatest one.
CLS
INPUT “ENTER FIRST NUMBER”; N
FOR I = 2 TO 10
INPUT “ENTER NEXT NUMBER”; G
IF G > N THEN
N=G
NEXT I
PRINT “THE GREATEST NUMBER IS” ; N
ENDIF
END

Practical Time-13

Write a QBASIC program to display the sum of numbers from 1 to 100.
CLS
S= 0
FOR I = 1 TO 100
S=S+I
NEXT I
PRINT “The total sum is:” ; SUM
END

Practical Time-14

Write a QBASIC program to convert the temperature Celsius into Fahrenheit.
CLS
INPUT “Enter the temperature in Celsius”; C
F = (9*C/5) + 32
PRINT “The temperature in Fahrenheit is:” ; F
END

288 New Gateway to Computer Science Book-8

Practical Time-15

Write a QBASIC program to display the odd numbers from 99 to 1.
CLS
FOR I = 99 TO 1 STEP -2
PRINT I
NEXT I
END

Practical Time-16

Write a QBASIC program to display the series : 3 , 6, 9, 12, 15, 18, 21, 24, 27, 30.
CLS
FOR I = 3 TO 30 STEP 3
PRINT I
NEXT I
END

New Gateway to Computer Science Book-8 289

Specification Grid

Computer Education Class 8

Full Marks: 50 Pass Mark: 20 Time: 1:30 Hours

Theory Part

S. Area Topics No. of Types of questions
N. questions

1 Fundamental • Introduction of computer Knowledge Skill Low High
Knowledge • Introduction of Hardware Base Ability Ability
& Skill Computer • Introduction of Software
• Input and Output Devices
• Storage Devices b/w 1 11 1
• Introduction of Word Processing
• Introduction of Spread Sheet
•Introduction of Presentation
Package

2 ICT, Ethics and • Concept ICT technology
Cyber Laws • Computer Ethics and cyber law
• Computer Virus, remedy and
protection 2 1 1
• Introduction data communication
and Network
• Introduction of Web design
• Use of Website, Internet and
E-mail

3 Number System • Decimal to Binary and Vice versa
• Binary Calculation: Addition and 1
Multiplication 1

4 Computer Graphics •Introduction of computer 2 1 1
Graphics
• Uses of computer graphics in
various field

5 Concept of computer • Basic Concept of Computer 1 1

Programming Programming

Total 10 3 32 2

Practical Part Time: 1: 00 Pass Marks: 20
Full Marks:50

SN Area Topics No of Marks
Question

1 Fundamental • Creating document by following instructions.
Knowledge
& Skill Computer • Create four different types of data and show in chart

• Insert given data according to instructions 1 25

• To create four Power Point slides and presentation

2 Computer Graphics • Develop simple Web page using HTML Tags 1 25
• Develop four colour Book Design

290 New Gateway to Computer Science Book-8

MODEL QUESTION (Issued by CDC)

Class: 8 Full Marks: 50

Time: 1 Hour 30 minutes Pass Marks: 20

Group ‘A’ [10X1=10 Marks]

Very Short Questions

1. Who is known as the father of computer?

2. What is the name of the first electro-mechanical computer?

3. Which network is called the network of networks?

4. What do you call for the first page of website?

5. In which number system does the digital computer work?

6. How many number are there in a binary number system? Write them.

7. Write down any two photo editing software.

8. What is a multimedia?

9. Write the full form of:

i. W.W.W ii. G.U.I iii. U.N.I.V.A.C iv. Ms-word

Group ‘B’ [7X4=28 Marks]
Short Questions

1. What is an I.P.O. cycle? Describe with figure.

2. List out the components of MS-Excel.

3. Write down any five provisions of cyber ethics.

4. List out the devices required to connect the internet.

5. Write the features of a page layout.

6. Write short notes on:

i. Photoshop ii. Adobe InDesign

7. (a) Convert decimal number into binary numbers.

i. 75 ii. 100

(b) Binary Addition

i. 1012 + 1112 ii. 1112 + 1002

Group ‘C’ [2X6=12 Marks]
Long Questions

1. What is a flowchart? Draw the symbols used in flow chart and write its work.

2. What is an operating system? Write its types and describe in brief.

New Gateway to Computer Science Book-8 291

NOTE

292 New Gateway to Computer Science Book-8


Click to View FlipBook Version