Hand tool
This tool is used to move the
image horizontally or vertically
on the screen.
Open the required image.
Click on the hand tool from
the tool box.
Click on the image then
drag it as required.
Drag the mouse pointer over the part of the picture and release the
mouse.
Text tool
We can use this tool to type the text, symbols, characters and sentence on
the selected area. We can also type the text over the image as well.
Create a new blank canvas or open any picture file.
Click on the text tool from the tool box.
Drag on the location where you want to type the text.
A cursor will appear, type the text as required.
Clone stamp tool
Clone stamp tool allows you to copy one area of an image onto another area
of an image.
Open an image.
200 New Gateway to Computer Science Book- 7
Click on the clone tool from the tool box.
Keep on pressing ALT key and click on the area of the image.
Click on the new area of the image to apply the effect.
Setting brightness and contrast
We can change the brightness and contrast of an image as per requirements.
Open the image in which you want to
apply the brightness or contrast.
Click on image menu and select
adjustment options.
Click on Brightness / Contrast option.
A brightness / contrast dialog box
appear.
Change the value of brightness and
contrast as per required and click on
OK to apply it.
Flip or rotate the image
This option helps to rotate or flip the image either horizontally or vertically.
Open the required image that you want to rotate.
Click on the image menu and select the image rotation option.
A list will appear, choose the required rotation option
Computer Graphics 201
(If you select the option as 900 Clockwise, the normal image looks as the
right figure shown above.)
Saving the image in different format
You can save your drawing in different format like .JPG, .JPEG, .GIF, .TIF,
.BMP etc. The following are the ways of saving the Photoshop image in
different format.
Prepare an image in a
Photoshop.
Click on the file menu.
Choose the save or save
as option.
Type the file name on
the file name box.
Click on the save as
type drop down option
to view the various file
format as below.
Select the required file format.
Finally click on the save button to save the file.
202 New Gateway to Computer Science Book- 7
Working with layer
Layers are most powerful features as they are individual slices of
information that can be moved to create your image composition. With
layers, you can draw, edit, paste, and reposition elements on one layer. The
layer panel list all layers, layer groups and layer effects in an image. You
can use the layer panel to show and hide layers, create new layers and to
work with group layers.
To show or hide layers
To show
Click on the windows menu.
Click on the Layer from the list of options.
To hide
Click on the windows menu.
Select the remove the tick sign from the list of options.
To add new layer
Click on the layer
menu.
Choose the new from
the option .
Again, click on the Layer.
A new layer box will appear.
Type the name of the layer in the Name box and click on the OK.
Computer Graphics 203
Now, the layer will add in the layer palate as you can see below.
Opacity and fill
The Opacity and Fill commands allow you to
change the opacity (transparency) of a layer.
In the rectangle shown below, notice that the
Opacity change affects both the fill and stroke of
the rectangle and the Fill change affects only the
fill and not the stroke of the circle. Opacity and Fill
changes can drastically change the appearance
of a layer and are recommended when trying to
blend objects or make adjustments more subtle.
204 New Gateway to Computer Science Book- 7
Locking layers
Locking the layers can be a handy tool when
working in Photoshop. There are several ways to
lock the layer or layer contents. Each layer can be
locked by selecting the layer, and then selecting
the type of lock. Below are the types of locks.
Layer buttons
There are several buttons that are
located at the bottom of the layers
palette. Many of these buttons
perform actions that can be found in
other locations within the program.
Link layers: Select two or more
layers and click this button to link them
together. Linking means that they will
all move together.
Computer Graphics 205
Add a new layer style: This button allows you to add a new layer
style without going to Layer and selecting Layer Style in the menu.
Add layer mask: Clicking this will add a new layer mask to the
selected layer.
Create new fill or adjustment layer: This button allows you to
add a new layer style without using the Adjustments Palette.
Create a new group: Click this to create a new group. Drag layers
into this group to organize them.
Create a new layer: Clicking this will create a new, empty layer.
Delete layer: Select a layer or multiple layers and click this button to
permanently delete them.
Raster Image
A raster graphics image is a dot matrix data structure, representing a
generally rectangular grid of pixels, or points of colour, viewable through
a monitor, paper, or other display medium. Raster images are stored
in image files with varying formats. The photos taken by the digital camera
are the raster images which contain the large number of pixels. We can
store the raster images by using .bmp, .tif, .jpg, etc. file extensions.
Vector Image
Vector graphics is the creation of digital images through a sequence of
commands or mathematical statements that places lines and shapes in a
given two-dimensional or three-dimensional space. This graphics required
more space than the bitmap images. The files are generally stored in .ai ,
.eps, .drw, .svg, etc.
206 New Gateway to Computer Science Book- 7
Quick Learn!
¬¬ A cropping is the way of removing portions of a photo or image to
create focus or strengthen the composition.
¬¬ An eraser tool is used to remove the certain area or part of the image.
¬¬ Zoom tool is used to enlarge the size of the image.
¬¬ Flip or rotate the image option helps to rotate or flip the image either
horizontally or vertically.
¬¬ Layers are most powerful features as they are individual slices of
information that can be moved to create your image composition.
¬¬ The opacity and fill commands allows you to change the opacity (or
transparency) of a layer.
¬¬ Locking the layers can be a handy tool when working in Photoshop.
¬¬ We can store the raster images by using .bmp, .tif, .jpg, etc. file
extensions.
¬¬ Vector graphics is the creation of digital images through a sequence
of commands or mathematical statements that place lines and
shapes in a given two-dimensional or three-dimensional space.
1. State whether the given statements are true or false.
a. A computer graphic is the technology that deals with designs and
pictures on the computer.
b. There are two types of computer graphics they are Interactive
Computer Graphics and Non Interactive Computer Graphics.
c. An interactive computer graphics is the computer graphics in
which a user does not have any kind of control over the image.
d. A cropping is the way of removing portions of a photo or image to
create focus or strengthen the composition.
e. We cannot use text tool to type the text, symbols, characters and
sentence on the selected area.
Computer Graphics 207
f. A flip or rotate the image option helps to crop the image either
horizontally or vertically.
g. We can store the raster images by using .bmp, .tif, .jpg etc. file
extensions.
h. Rubber tool is used to enlarge the size of the image.
2. Fill in the gaps with correct word(s).
a. There are two types of computer graphics. They are interactive
and ......................
b. ……………….. Graphics involve two way communications between
the computer system and the user.
c. A Photoshop software provides many image editing features
which uses a …………………..editing system that enables image
creation and altering with multiple overlays that support.
d. …………………. is used to remove the certain area or part of the
image.
e. With …………………., you can draw, edit, paste, and reposition
elements on one layer.
f. A ………………………..image is a dot matrix data structure,
representing a generally rectangular grid of pixels, or points
of colour, viewable through a monitor, paper, or other display
medium.
g. …………………….. graphics is the creation of digital images through
a sequence of commands or mathematical statements that place
lines and shapes in a given two-dimensional or three-dimensional
space.
3. Answer the following questions.
a. What is computer graphics? Write down the types of computer
graphics.
b. What is a Photoshop? What is the use of Photoshop in computer
graphics?
c. Name any ten tools of adobe Photoshop CC.
d. What do you mean by crop?
208 New Gateway to Computer Science Book- 7
e. What is the use of lasso and blur tool?
f. For what purposes can we use text tool and stamp tool?
g. What are the layers? Write down the steps to hide the layers from
the working screen.
h. Define raster image and vector image.
4. Write down the steps to do the following task.
a. Creating a new working canvas.
b. Working with eraser tool.
c. Working with hand tool.
d. Saving the images in different format.
e. To add a new layer.
Project Work and Activity
a. Insert an image and crop the certain part of the image.
b. Use text tool inside a picture and type the text.
c. Use blur tool in the image and observe the effect.
d. Insert an image and use zoom tool to look at it in a larger view and smaller
view.
e. Insert the picture, increase and decrease the brightness and contrast.
f. Show and hide the layer from the working screen.
Computer Graphics 209
Chapter Multimedia
16
Learning Outcomes
At the end of this lesson, the students will be able to:
define the multimedia.
tell the advantages and disadvantages of using multimedia.
explain the elements of multimedia.
describe multimedia file, multimedia software, AGP, MPC, multimedia
players,
tell the application areas of multimedia.
Let's Update
. On March 20, 2018 AD, Sophia, a humanoid robot that was granted
citizenship by the Kingdom of Saudi Arabia was brought to Nepal for the
first time.
. Sophia (humanoid robot )was built by the Hong Kong-based company
Hanson Robotics in 2015.
Introduction
Multimedia technology refers to interactive, computer-based applications
that allow people to communicate ideas and information with digital and
print elements. It can use more than one media to present information
in a more attractive and interesting way. We can say that multimedia is
a combination of multiple media such as text, audio, video and image.
Multimedia technology applies interactive computer elements, such
as graphics, text, video, sound, and animation to deliver a message.
Multimedia is usually more enjoyable and informative than the text.
210 New Gateway to Computer Science Book- 7
Basic terminology
Multimedia file
A multimedia file can be any computer file that plays audio and video, audio
only, or video only. Some examples of popular multimedia files include the .
mp3 audio file, .mp4, video, avi video, and wmv files.
Multimedia software
Multimedia software is a software that is capable of playing or recording
audio files or playing or recording video files. Windows Media Player, VLC
player, Quick time player, MP3 player are the popular multimedia software.
Accelerated Graphics Port (AGP)
It is an advanced port designed for Video cards and 3D accelerators
developed by Intel and introduced in August of 1997. AGP introduces a
dedicated point-to-point channel that allows the graphics controller direct
access to the system memory.
Multimedia Personal Computer (MPC)
The MPC was developed in 1990 AD. MPC computers are capable of
running programs that combine video, animation, audio, and graphics
Windows Media Player
Windows Media Player is a media player and media library application
developed by Microsoft that is used for playing audio, video and viewing
images on personal computers.
VLC media player (VLC)
It is a free and open-source, portable
and cross-platform media player and
streaming media server written by the Video
LAN project in 2001 AD. It supports a wide
Multimedia 211
variety of operating systems like Windows, iOS, Linux, Android, Solaris,
etc. VLC supports a wide range of file formats including: Audio formats
(mp3, AAC, AC3, RealAudio, WMV), Video Format (AVI, FLV, Quick Time
File Format, MP4, WAV, MPEG, WMV) and Subtitles (DVD-Video, SVCD,
DVB, MPEG-4, etc.)
Advantages of multimedia
It is a very powerful tool for the teaching learning activities so that
learning process is becoming easier.
It is used to prepare an interesting and eye catching advertisement to
promote the business.
It can be used for a variety of listeners, ranging from one person to the
whole group.
It helps to create interesting types of video games, movies and cartoons.
It is used to develop an interactive web page.
It enhances the message by adding emotion and visuals.
Disadvantages of multimedia
It is expensive system to establish.
Trained person is required to work with this.
The multimedia files are difficult to attach within an email because it
has large file size.
It may not be suitable for every user.
It is not always compatible.
Elements of multimedia
A multimedia is completely meaningful because of its some elements which
we are going to discuss below.
Text
Text has the most impact on the quality of the multimedia interaction.
Generally, text provides the important information. Text acts as the keystone
tying all of the other media elements together. Text in multimedia systems
can express specific information, or it can act as a support for information
contained in other media items.
212 New Gateway to Computer Science Book- 7
Image or Graphic
It is a visual multimedia element which represents a photo, illustration, 3D
or diagram. In the computer, a graphic is a file such as JPEG or GIF, there
is graphic formats. Graphic is a picture image in the computer. We can use
computer graphic to design a picture, flash or game. We can make more
effect in the picture, make a flash video or make a game by using graphic
software.
Audio
Audio is one of the multimedia elements. Audio is sound within the audio
range available to humans. Commonly, we can hear many audio from the
internet, radio, MP3, computer and so on. Now, we can listen to music or
download music from website.
Video
Video is another multimedia element. It is the technology of electronically
capturing, recording, processing, storing and transmitting of images that
show scenes in motion. We can find many videos from the internet. Some
people make a flash video and upload to website to share with others. We
also can use video conference to communicate with friends or family. We
can watch movie from online or download it.
Animation
Animation is one of the best elements of the multimedia. Animation is
a visual technique that provides the illusion of motion by displaying a
collection of images in rapid sequence. When the images are viewed rapidly,
your eye fills in the details and the illusion of movement is complete. We
can make images become Animation by using software. The purpose of
Animation is to entertain to everyone.
Multimedia 213
Quick Learn!
¬¬ Multimedia technology refers to interactive, computer-based
applications that allow people to communicate ideas and information
with digital and print elements.
¬¬ Multimedia is a combination of multiple media such as text, audio,
video and image.
¬¬ Multimedia technology applies interactive computer elements, such
as graphics, text, video, sound, and animation, to deliver a message.
¬¬ A multimedia file can be any computer file that plays audio and
video, audio only, or video only.
¬¬ Windows Media Player, VLC player, Quick time player, MP3 player,
etc. are the popular multimedia software.
¬¬ Windows Media Player is a media player and media library
application developed by Microsoft.
¬¬ Multimedia is a very powerful tool for the teaching learning activities
so that learning process is becoming easier.
Components required for multimedia
A high range of processor and motherboard
Sound card and graphic cards with larger capacity
Larger memory and storage devices
A good display unit with high resolution and size
Digital camera and movies camera to capture the pictures and videos
A high resolution of scanner
Overhead Projector
Multimedia software
214 New Gateway to Computer Science Book- 7
Application of multimedia
Multimedia plays a vital role in every sector. Some of the popular application
areas of multimedia are explained below.
Education
There is a great impact of multimedia in the field of education. Students
do not entertain with the traditional types of learning activities. The use
of multimedia in education can make more changes in the teaching and
learning activities. The interactive CD for different subjects like Science,
Mathematics, English, Computer and other subjects are 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 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 diagnose about the diseases. Multimedia technology can be used
to transform the information about the health services and produce public
awareness programs which can be broadcasted from different media.
Entertainment
These days, without multimedia, entertainment is almost impossible. With
the help of multimedia, we can record the 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 the 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.
Multimedia 215
Quick Learn!
¬¬ The use of multimedia in education can make more changes in the
teaching and learning activities.
¬¬ The concept of distance learning is also based on multimedia.
¬¬ The information related to health service can be exchanged with the
help of multimedia.
¬¬ 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 diagnose the diseases.
¬¬ Without multimedia, entertainment is almost impossible.
¬¬ To create and promote the business and products, we can use
multimedia.
¬¬ We can add animation in the advertisement to make it more effective
and interesting.
1. State whether the given statements are true or false.
a. Multimedia technology refers to interactive, computer-based
applications that allow people to communicate ideas and
information with digital and print elements.
b. A multimedia file can be any computer file that plays audio and
video, audio only, or video only.
c. Windows Media Player, VLC player, Quick time player, MP3
player, etc. are the popular multimedia hardware.
d. Windows Media Player is a media player and media library
application developed by Adobe Photoshop.
e. The concept of distance learning is also based on multimedia.
f. Without multimedia, entertainment is almost impossible.
g. To create and promote the business and products, we cannot use
multimedia.
216 New Gateway to Computer Science Book- 7
2. Fill in the gaps with correct word(s).
a. ………………… is a combination of multiple media such as text,
audio, video and image.
b. …………………. applies interactive computer elements, such as
graphics, text, video, sound, and animation, to deliver a message.
c. ………………..is a very powerful tool for the teaching learning
activities so that learning process is becoming easier.
d. The use of multimedia in ……………… can make more changes in
the teaching and learning activities.
e. ………………… tools are also used to provide health services all
over the world with the help of video conference.
f. We can add ……………. in the advertisement to make it more
effective and interesting.
3. Answer the following questions.
a. What is multimedia? For what purpose can we use multimedia
system?
b. Write down the advantages and disadvantages of multimedia.
c. Write any four multimedia and explain them in short.
d. What is VLC media player?
e. What are the components required to establish multimedia?
f. What are the application areas of multimedia?
g. What is the role of multimedia in ‘education’?
h. Define multimedia file and multimedia software.
i. What is the meaning of the term ‘Animation’?
j. Explain the role of multimedia in entertainment.
Presentation Work
a. Prepare a slide and conduct a presentation competition about your school.
b. Visit a FM studio station or radio station nearby your locality and observe
how the technologies are used over there.
Multimedia 217
Unit 5
Concept of Computer
Programming
Start
Read a, b, c
If a > b If a > c
If b < c Read A
Print b Print c
smallest
Stop
This unit covers the following chapters.
Chapter 17 Programming language and program designing tools
Chapter 18 Computer Programming in QBASIC
218 New Gateway to Computer Science Book- 7
Chapter Programming Language and
17 Program Designing Tools
Learning Outcomes
At the end of this lesson, the students will be able to:
tell about the programming tools.
differentiate between algorithm and flowchart.
list out the rules for designing flowcharts.
identify the various flowchart symbols.
define pseudocode.
Let's Update
. In 1801, a French weaver and merchant, Joseph Marie Jacquard, invented
a power loom that could base the design of a fabric upon punched wooden
cards.
. In 1947, Grace Hopper, an admiral in the US Navy, recorded the first
computer ‘bug’ in her log book as she was working on a Mark II computer.
. STEWARDESSES is the longest word that can be typed with only left
hand.
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.
Programming Language and Program Designing Tools 219
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 development-specific task. A programming tool is also
known as a software development tool.
Every system needs instructions to perform a task. Instruction is the
command that instruct the system. The set of instruction is called computer
program that is used to perform a specific task. Program is written using the
programming language. Programming languages are artificial languages
that are used to write a program code. It is the set of grammatical rules.
Instruction consists keywords, symbols, etc. Each programming language
has a unique set of keywords and special syntax for writing a program
code. To write the effective and error free programs, programmer needs
the knowledge of programming language.
Types of programming language
The types of programming languages are explain below.
Low level language
It is the machine dependent language. If we develop a program in a one
type of hardware then it is unable to run in another type of hardware. It is
difficult and time consuming to develop a program. A programmer needs
detailed knowledge about hardware to develop a program using low level
language. Low-level languages are designed to operate and handle the entire
hardware and instructions set architecture of a computer directly. Machine
level language and assembly languages are the low level languages.
Advantages of low level language
The computer understands this language directly.
It is directly understood by the computer.
220 New Gateway to Computer Science Book- 7
It can execute faster than other computer languages.
It is machine dependent so less chances of privacy.
Disadvantages of low level language
It is complex to develop a program.
It is machine dependent so unable to use in another computer.
Program needs detailed knowledge about the computer hardware.
High level language
It is the machine independent language. It is easy and less time consuming to
develop a program because it is similar to English language and has limited
keywords but machine doesn’t directly understand. It needs to translate in
machine level language for which language translator is needed.
Advantages of high level language
It is machine independent, so it can be easily used in different types
of computer.
It is easy to learn.
It requires less time for developing a program.
Disadvantages of high level language
The machine cannot understand it directly.
The machine needs a translator to understand it.
Program execution will be slower.
Tools for programming 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
Programming Language and Program Designing Tools 221
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.
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 more
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 principle 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: Read two numbers as num1 and num2.
Step 3: Add num1 and num2 and assign the result to sum.
Step 4: Display sum
Step 5: Stop
Write an algorithm to find out the area of a room.
Step1 : Start
Step 2 : Input the length of a room and store it in variable L.
222 New Gateway to Computer Science Book- 7
Step 3 : Input the breadth of a room and store it in variable B
Step 5 : Calculate the area with formula, Area = (LXB)
Step 6 : Display the area of room.
Step 7 :Stop
Flowchart
Flowcharts use special shapes or symbols to represent 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 eliminating 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 a list of activities inside each symbol.
Do not cross the flow lines with each other.
It should express all sections like input, process, logical and
output.
It should not be any programming language oriented.
Always use a connector if a flowchart is not sufficient in a page.
Programming Language and Program Designing Tools 223
Symbols used in flowchart
S.N Symbols name Symbol Description
1 Start / Stop
It indicates the starting and
ending of flowchart.
2 Input / Output It indicates input or output
operations.
3 Processing It indicates any calculations or
4 Decisions manipulations.
It is used to show the steps
involving comparison and
decision making.
5 Flow lines It shows the flow of control in a
program.
6 Connectors It indicates a junction point
7 Comment at which flowchart joins with
a part of flowchart to another
place or part.
It is used to write the comments
about the flowchart symbol.
224 New Gateway to Computer Science Book- 7
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 may be any software program or utility that
helps software developers to create, edit and debug the program.
¬¬ A programming tool is also known as a software development tool.
¬¬ An algorithm is a set of instructions designed to perform a specific
task.
¬¬ Algorithm is a step by step procedure to solve a given problem in a
finite number of steps.
¬¬ Flowcharts use special shapes or symbols to represent different
types of actions or steps in a programming process.
Some examples of flowcharts
Draw a flowchart to find out the sum of any two numbers.
Start
Read A
Read B
Sum = A + B
Print Sum
End 225
Programming Language and Program Designing Tools
Draw a flowchart for finding the smallest of three numbers
Start
Read a, b, c
If a > b If a > c
If b < c Read A
Print b Print c
smallest
Stop
Draw a flowchart to check whether the entered number is odd or even.
Start
Write
"Enter an integer"
Read x
x MOD 2 = 0 Yes
No
Display "Odd" Write "Even"
End
226 New Gateway to Computer Science Book- 7
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 to understand the programming
data flows that the final program is going to use.
1. State whether the given statements are true or false.
a. Program Design tools are the tools used to develop a program.
b. A programming tool may be any software program or utility that
helps software developers to create, edit and debug the program.
c. An algorithm is a set of instructions designed to perform a specific
task.
d. Algorithm uses special shapes or symbols to represent different
types of actions or steps in a programming process.
e. The use of input/output symbol is to indicate the starting of the
flowcharts.
f. We can use comment symbol to write the comments about a
flowchart symbol.
2. Fill in the gaps with correct word(s).
a. …………….. is a computer program that software developers use to
create, debug and maintain programs and applications.
b. A programming tool is also known as a …………………. development
tool.
c. ……………… is a step by step procedure to solve a given problem in
a finite number of steps.
d. The …………..symbol indicates the input and output operating in
flowchart.
e. …………………..shows the flow of control in a program.
f. ……………….. is a simple way of writing programming code in
English.
Programming Language and Program Designing Tools 227
3. Answer the following questions.
a. What is the use of program tool?
b. Define algorithm and flowcharts.
c. Write any three features of algorithm.
d. What are the uses of flowcharts?
e. Write any four rules for drawing the flowcharts.
f. Draw various symbols used by flowcharts.
g. What is pseudocode?
4. Write an algorithm and draw a flowchart to do the given
task.
a. To calculate the simple interest.
b. To calculate the area of a room.
c. To find the sum, product and differences of any two numbers.
d. To find out the smallest number among the three different
numbers.
228 New Gateway to Computer Science Book- 7
Chapter Computer Programming in
18 QBASIC
Learning Outcomes
At the end of this lesson, the students will be able to:
define QBASIC program and its features.
discuss the elements of QBASIC programming.
tell the types of variables and constants.
differentiate between QBASIC operators and various QBASIC statements.
Let's Update
. First microprocessor from Intel was Intel 4004.
. Email was invented before the World Wide Web!
. Facebook is available in more than 70 languages.
. Apple and Microsoft were among the first Work Networks that were
included in Facebook.
Introduction
QBASIC stands for Quick Beginners All-purpose Symbolic Instruction
Code. It is the most popular high level programming language. QBASIC is
the advance form of BASIC program. The BASIC program was developed
by John George Kemeny and Thomas Eugene in 1964 AD at USA. This
language is quite simple to understand and has been adopted by most of
the microcomputers.
Computer Programming in QBASIC 229
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 task
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.
Double click one exe file of
QBASIC.
Now, you can see the
QBASIC screen as below.
Press Esc key to remove the
welcome dialog 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 function. QBASIC has the
character set consisting of the following elements:
Alphabets: A, B, C,....Z
Digits: 0, 1, 2........,9 and
Special characters: + - * / ( ) . , $ ; ,: ,= ,> ,< , ^ etc.
230 New Gateway to Computer Science Book- 7
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
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 M
x=20
Salary = 25000
a=5
Age = 12
A=13.5
B=25
SUM=A+B
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 long.
Do not use space between the names of variables.
Always start the name of variable from alphabet and can follow by
numbers.
Never use QBASIC reserved words as a name of variables like CLS,
INPUT, CLS, and PRINT etc.
Computer Programming in QBASIC 231
Types of variable
Types of variable The number/character it can Example
Integer A whole number between -32,768 and A%
32,767
Long Integer A whole number between -2,147,483,648 A&
and +2,147,483,648
Single precision Number from -3.37X10^38 to 3.37 X A!
10^38
Double precision Number from -1.67X10^308 to A#
1.67X10^308
String O to 32,767characters A$
Constants:
Constant is an identifier whose value does not change during the program
execution. The value of constant are fixed value which is used in the
program. There are two types of constants that are are given 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$="Neelakantha Dhading"
232 New Gateway to Computer Science Book- 7
Quick Learn!
¬¬ QBASIC stands for Quick Beginners All-purpose Symbolic Instruction
Code.
¬¬ QBASIC is the most popular high level programming language.
¬¬ The BASIC program was developed by John George Kemeny and
Thomas Eugene in 1964 AD in USA.
¬¬ The QBASIC Character Set consists of alphabets (both small and
capital), numbers (0 to 9) and special characters.
¬¬ Variable is a symbolic name that is used to store data (numbers, text,
string, special characters etc.) in the computer memory.
¬¬ Numeric Variable is a symbolic name which is used to store only the
numeric data.
¬¬ String Variable is a symbolic name which is used to store text, text
with numbers.
¬¬ Constant is an identifier whose value does not change during the
program execution.
¬¬ Numeric constant is a numeric value which is used in program. In
numeric constant comma and blank space are not allowed to use.
¬¬ String constant is the collection of numbers or texts or text with
numbers followed by the $ sign.
Operators
Operators are the sign or symbols that are used to do mathematical
calculations like addition, subtraction, multiplication and division. There
are different types of operators in QBASIC. They are Arithmetic Operators,
Relational Operators, Logical Operators and Sting Operator, etc.
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.
Computer Programming in QBASIC 233
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 sting 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
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.
234 New Gateway to Computer Science Book- 7
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:
OROperatorreturns‘True’ifoneoftherelationalexpressionsreturns‘True’.If
all the relational expressions return ‘False’, then only the result will be ‘False’.
Truth Table for OR operator
INPUT (A) INPUT (B) Output (A OR B)
TF T
TT T
FF F
FT 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)
TF
FT
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.
Computer Programming in QBASIC 235
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.
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
INPUT “First Number”; A
INPUT “Second Number”; B
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
236 New Gateway to Computer Science Book- 7
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 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 Output
PRINT “Learning QBASIC is fun.” We are learning QBASIC programming
PRINT 98511 Learning QBASIC is fun
PRINT “The number is:” ; 22004 98511
END 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”]; or [Variables]
Computer Programming in QBASIC 237
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
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
Quick Learn!
¬¬ Operators are the sign or symbols that are used to do mathematical
relational and logical calculations.
¬¬ Arithmetic Operators are used to perform mathematical calculations
like addition, subtraction, division, multiplication and exponential.
¬¬ Relational Operators are used to compare the value of variables.
¬¬ Logical Operators combine two or more relational expressions to
evaluate a single value as True or False.
¬¬ AND operator returns ‘True’ when all the results returned from
individual relational expressions are ‘True’ otherwise it returns
‘False’.
¬¬ OR Operators return ‘True’ if one of the relational expressions
returns ‘True’
¬¬ NOT Operator operates on one operand and returns ‘True’ if the
logical operation returns ‘False’.
238 New Gateway to Computer Science Book- 7
Practical Section of QBASIC
Run the each given program in your computer lab and write the output in
the spaces provided.
Practical : 1
Write a QBASIC program to print the text as below.
This is me Dinesh Adhikari.
I am from Dhading Bensi.
I love my teaching job.
Learning QBAIC is fun.
CLS
PRINT “This is me Dinesh Adhikari.”
PRINT “I am from Dhading Bensi.”
PRINT “I love my teaching job.”
PRINT “Learning QBAIC is fun.”
END
Practical : 2
Write a QBASIC program to print the sum of 200 and 300.
CLS
LET A = 200
LET B = 300
LET C = A+B
PRINT “The Sum of 200 and 300 is:”; C
END
Practical : 3
Write a QBASIC program to find out the average of any two numbers.
CLS
Computer Programming in QBASIC 239
INPUT “Enter first number”; A
INPUT “Enter second number”; B
AVG = (A+B)/2
PRINT “The average value is”; AVG
END
Practical : 4
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 : 5
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 : 6
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 the number is”; A
END
240 New Gateway to Computer Science Book- 7
Practical : 7
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
Practical : 8
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
Practical : 9
Write a QBASIC program to input your Name, Address, Section and Phone.
CLS
INPUT “Enter your name”; N$
INPUT “Enter your address”; A$
INPUT “Enter your Section”; S$
INPUT “Enter your Phone”; P
PRINT “My name is:::::”; N$
PRINT “My address is:::::”; A$
PRINT “I am in section:::::”; S$
PRINT “My phone number is:::::”; P
END
Computer Programming in QBASIC 241
Quick Learn!
¬¬ 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
¬¬ The commonly used QBASIC statements are: LET, PRINT, INPUT,
CLS, END and REM.
¬¬ LET is an assignment statement. It is used to assign the value to a
variable
¬¬ PRINT statement provides output 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.
1. State whether the given statements are true or false.
a. QBASIC stands for Quick Beginners All-purpose Symbolic
Instruction Code.
b. QBASIC is the most popular low level programming language.
c. Constants are the symbolic names that are used to store data in
the computer memory.
d. Numeric Variable is a symbolic name which is used to store text,
text with numbers.
e. Operators are the sign or symbols that are used to do mathematical
relational and logical calculations.
f. Arithmetic operators combine two or more relational expressions to
evaluate a single value as True or False.
242 New Gateway to Computer Science Book- 7
g. AND operator returns ‘True’ when all the results returned from
individual relational expressions are ‘True’ otherwise it returns ‘False’.
h. A statement is a computer instruction written in a source language
i. PRINT statement is used to input the data for the processing.
j. INPUT statement in QBASIC is used to accept the data item from the
user.
2. Fill in the gaps with correct word(s).
a. The BASIC program was developed by …………….. and
…………………… in 1964 AD in USA.
b. The QBASIC ………………. consists of alphabets (both small and
capital), numbers (0 to 9) and special characters.
c. Numeric Variable is a symbolic name which is used to store only
the …………. data.
d. Constant is an……………. whose value does not change during the
program execution.
e. …………….. is a numeric value which is used in program. In
numeric constant comma and blank space are not allowed to use.
f. String ……………. is the collection of numbers or texts or text with
numbers followed by the $ sign.
g. ……………… are used to perform mathematical calculations like
addition, subtraction, division, multiplication and exponential.
h. ………………. are used to compare the value of variables.
i. ……………… Operator returns ‘True’ if one of the relational
expressions returns ‘True’
j. ………………….is an assignment statement. It is used to assign the
value to a variable
3. Answer the given questions.
a. What is QBASIC programming? When it was developed?
b. Write down the features of QBASIC programming.
c. Write down the elements of QBASIC.
d. What are character set and variables in programming?
e. What are the types of variables?
f. Write any four rules for writing the variable name.
g. What is constant? Write its types in short.
Computer Programming in QBASIC 243
h. What is QBASIC operator? Write down the types of operators.
i. Define arithmetic and relational operator with examples.
j. What is logical operator? Name the commonly used logical
operator.
k. Draw a truth table for AND, OR and NOT operator.
4. Explain the following QBASIC statements.
a. LET b. CLS c. REM
d. PRINT e. INPUT f. END
5. Write down the QBASIC program for the followings.
a. Write a program to find the sum of any three numbers.
b. Write a program to find the sum, product and differences of any
two numbers.
c. Write a program to find out the average of any five numbers.
d. Write a program to find the area of a circle.
e. Write a program to calculate the simple interest where principal,
time and rate is given.
f. Write a program to convert the temperature Celsius into
Fahrenheit.
g. Write a program to calculate the area of four walls of a room.
244 New Gateway to Computer Science Book- 7
Quiz Section
1. Group of instructions that directs a computer is called..........
A. Storage B. Memory
C. Logic D. Program
2. Which of the following is not an output device of a computer?
A. Printer B. keyboard
C. VDU D. CRT screen
3. A computer has no more sense than a light.......
A. bulb B. pen
C. switch D. pad
4. The first large scale electronic computer which became operational in 1946
and contained approximately 18000 vacuum tubes and could perform 300
multiplications per second was known as..............
A. ILLIAC B. ENIAC
C. JOHNIAC D. EDSAC
5. A computer program that converts an entire program into machine language
at one time is called a/an........
A. interpreter B. simulator
C. compiler D. commander
6. In latest generation computers, the instructions are executed......
A. Parallely only B. Sequentially only
C. Both sequentially an parallely D. All of the above
7. Program execution time would be minimum if the programs are written in....
A. Machine Language B. Assembly language
C. High level language D. All of the above
8. A small square or rectangular piece of silica on which several layers of an
integrated circuit are etched or imprinted is called........
A. VLSI B. micro C. wafer D. chip
9. The processing capability of a microcomputer can be enhanced with the help
of.....
A. addition processor B. expansion cards
C. secondary memory D. buffer memory
Quiz Section 245
10. Computer programmer...............
A. does all the thinking for a computer
B. can enter input data quickly
C. can operate all types of computer equipment
D. can draw only flowchart
11. What is the name of the earliest calculating machine which was based on
concepts found in modern computers but was unfortunately never built?
A. Babbage’s Difference Engine B. Pascal’s Adder
C. Leibnitz’s Multiplier D. Differential Analyser
12. The first machine to successfully perform a long series of arithmetic and
logical operations was:
A. ENIAC B. Mark I
C. Analytic engine D. UNIVAC-I
13. Which is used for manufacturing chips?
A. Bus B. Control unit
C. Semiconductors D. (a) and (b) only
14. The 0 and 1 in the binary numbering system are called binary digits or _____
A. bytes B. kilobytes
C. decimal bytes D. bits
15. Floppy disks which are made from flexible plastic material are also called?
A. hard disks B. high-density disks
C. diskettes D. templates
16. Which of the following is responsible for coordinating various operations
using timing signals?
A. Arithmetic-logic Unit B. Control unit
C. Memory unit D. Input/Output unit
17. All calculations are performed and all comparisons are made in _____ unit.
A. control unit B. arithmetic-logic unit
C. central processing unit D. primary storage unit
18. Point out the odd item amongst the following.
A. Computer mouse B. Touchpad
C. Light pen D. Printer
19. Which of the following is a part of the Central Processing Unit?
A. Printer B. Keyboard
C. Mouse D. Arithmetic Logic Unit
246 New Gateway to Computer Science Book- 7
20. Which of the following is used as storage locations both in the ALU and the
control section of a computer?
A. accumulator B. register
C. adder D. decoder
21. What is the name of the computer terminal which gives paper printout?
A. Display screen B. Soft copy terminal
C. Hard copy terminal D. Plotter
22. Primary storage is _____as compared to secondary storage.
A. Slow and inexpensive B. Fast and inexpensive
C. Fast and expensive D. Slow and expensive
23. In the IBM PC-AT, what do the words AT stand for?
A. Additional terminals B. Advance technology
C. Applied technology D. Advanced terminology
24. The punched card used in the IBM System/3 contains
A. 80 columns B. 120 columns
C. 96 columns D. 126 columns
25. Which was the first computer to use transistors instead of vacuum tubes?
A. Intel-650 B. Burroughs E-101
C. Datamatic-1000 D. IBM-1401
26. A CPU’s processing power is measured in:
A. IPS B. CIPS
C. MIPS D. nano-seconds
27. Which of the following is non-impact printer?
A. Drum printer B. Line printer
C. Chain printer D. Laser printer
28. The personal-computer industry was started by:
A. IBM B. Apple
C. Compaq D. HCL
29. The operation of a digital computer is based on _____ principle.
A. counting B. measuring
C. electronic D. logical
30. Which of the following memories needs refresh?
A. SRAM B. DRAM
C. ROM D. All of the above
31. Which of the following is not a sequence storage device?
A. Magnetic disk B. Magnetic tape
C. Paper tape D. All of the above
Quiz Section 247
32. In 1830, Charles Babbage designed a machine called the Analytical Engine
which he showed at the Paris Exhibition. In which year was it exhibited?
A. 1820 B. 1860
C. 1855 D. 1870
33. Which of the following is used to check for errors in RAM chips?
A. ROM chip B. Microprocessor chip
C. Parity chip D. EPROM chip
34. Which of the following is not an alternative name for primary memory?
A. Main memory B. Primary storage
C. Internal storage D. Mass storage
35. Which of the following isn’t used in the storage phase of a computer-based
information system?
A. Magnetic B. Keyboard
C. Diskette D. Hard disk
36. CD-ROM is a
A. Semiconductor memory B. Memory register
C. Magnetic memory D. All of the above
37. A modern digital computer has
A. extremely high speed B. large memory
C. almost unlimited accuracy D. All of the above
38. What is meant by computer literacy?
A. Knowing what a computer can and cannot do
B. Ability to write computer programs
C. Knowing computer related vocabulary
D. Ability to assemble computers
39. Everything computer does is controlled by its
A. RAM B. ROM
C. CPU D. Storage devices
40. Which of the following is a non-impact printer?
A. Daisy wheel printer B. Drum printer
C. Laser printer D. All of the above
41. A device or system not directly connected to the CPU is
A. On-line B. Keyboard
C. Memory D. Off-line
248 New Gateway to Computer Science Book- 7
42. The microprocessor of a computer cannot operate on any information if that
information is not in its:
A. secondary storage B. main storage
C. ALU D. logic unit
43. A device which converts human readable data into machine language is
A. Card reader B. Card punch
C. Punched paper tape D. Character reader
44. What digits are representative of all binary numbers?
A. 0 B. 1
C. Both (a) and (b) D. 3
45. Which of the following is required when more than one person uses a central
computer at the same time?
A. terminal B. light pen
C. digitizer D. mouse
46. The language that the computer can understand and execute is called
A. Machine language B. Application software
C. System program D. All of the above
47. The basic components of a modern digital computer are :
A. Input device B. Output device
C. Central processor D. All of the above
48. An input device that converts data punched into paper lape into a binary
format is
A. Page reader B. Paper tape punch
C. Paper tape reader D. Card punch
49. A memory in which the information is stored last is on top & is retrieved first
is known as
A. PROM B. Buffer C. Stack D. RAM
50. The most popular language for interactive use is
A. COBOL B. PASCAL
C. BASIC D. FORTRAN
51. An error in computer data is called
A. Chip B. Bug
C. CPU D. Storage devices
52. Which of the following is a secondary memory device?
A. Keyboard B. Disk
C. ALU D. All of the above
Quiz Section 249