Vous êtes sur la page 1sur 95

Computer science First Class Lecture 1

HistoricalBrief
1- The First Computer
Man's need to handle data & information increases with the evaluation of
society& with industrial development it was Blaise Pascal in 1647 who
designed an adding machine it was the first ever calculation machine to
calculate taxes in 1666 Morland made a made a calculating machine do
adding & Subtracting ,later he improved it in 1673 to do multiplying ,
also in that period Leibinz designed a machine do all four calculating
operations& finding root based on algebraic principles it was called
Stepped Reckoner .In 1830 Charles Babbage designed the Difference
engine it operate based on Number difference then in 1859 he also design
a Big & Complicated Machine called the Analytic Engine it had the five
basic consumptions of a modern day computer and the possibility to take
a decisions between Two course of action the speed was 60 addtion per
second that is way he was called the father of the computer.
his work inspired lady Ada Augesta who suggested that computer should
Be programmed to solve problems, she was interested in the problem of
computing , suggested that computer will be programmable in the future
that is why she is the first programmer in the world and the first
programming language was named after her (ADA)
in 1880 Dr.Hreman Hollerith developed A Punched card system design a
sorting & punching Machine for general population Counting using a
code known as Hollerth code was to store information which can be read
a sorting machine by storing data in punched card was punched by a
machine in which that the card is the stored information ,1890 this
machine was bought By (international Business Machine Company ) also
Known as IBM .
in 1935 the first digital computer was Z1 it was designed by (Konrad
Zuse ) it had a keyboard and Output unit then he design Z2 it used electro
magnetic storage device it was bought by Siemens.
In 1943 the first computer was designed (Harvard Mark I ) in the Second
World War it was 15 m length 24 m Height it depended on Vacuumed
vulvae it contained 1000 of them , in 1945 (mauckly & Eckart ) designed
A Computer Called (ENI AC) Electronic Numerical Integrator And
Calculator it was faster than mark I But it was more heaver & Bigger it
Contained 1800 tube ,in 1949 J .W.Newman made (EDSAC) with
software and based on programming .
In 1950's IBM Produced (IBM 701) computer for commercial Use then
later was followed By (IBM 704) it was the beginning of computer as
Known now.


Computer science First Class Lecture 1
2-babbage Criteria
Charles babbage was the first to give a definition of a computer
,According to Him a machine is called a computer when if it
satisfies the following criteria

1. it must be able to solve of arithmetic & logical
calculations
2. the machine must have some type of storage unit where it
can store data which may be required by the user .
3. the machine must have some Input-Output Device
through which it can communicate with the User.
4. The machine must have some kind of decision making
power













Charles Babbage 's difference engine Konrad Zuse's Z1

3-Computers in I raq
The first computer entered Iraq in 1963 For Iraq Petroleum Company
(IPC) in Karkuk it was a second generation computer (IBM 1401) then in
1966 four computers entered Iraq
1. NCR 315 (J apanese) For Iraqi National Electricity Administration
2. ICL 1902 (British) For Iraqi Railways Administration
3. Two IBM 1130 (USA) for Ministry of Health & College of
Engineering University of Baghdad
Then in 1968 two computers entered Iraq for ministry of Planning & The
Central Statistical Board then 1985 Electrical Industries Company (EIC)
Computer science First Class Lecture 1
Assembled NEC PC 6001 then 1988 assembled Olivetti (IBM XT)
Compatible 1990 Saladin Company Assembled an IBM XT compatible
Computer Science & Engineering entered in Iraqi Universities in 1970's
In the 1980's Iraqi High schools started teaching computer science.
3-Computer Generations
This term means the evaluation of computers electronically throw time
after inventions , or also an be the advancement in the felid of computer
Hardware & software in earlier days the term means hardware only
3-1First Generation (1938-1952)
This generation began with (IBM 701)& These computers used vacuum
tubes or valve which worked on the principles of thermionic emissions .
the vacuum contain filaments which on heating , emitted electrons . at
that time the vacuum tube was the only medium can process any electron
signal, it can perform mathematical calculations in 0.001Sec .
the Major software development was programming language is
FORTRAN form word Formula and Translation by IBM ,
but that generations had has limitations & drawback
1- the size was very Huge and was not portable
2- Extremely slow
3- Unreliable as filament frequently burnt out
4- Needed an initialization time to start operations
5- Needed a large amount of power to run the machine
6- Very High Heat generations & radiations
7- Needed Heavy of air conditioning system
8- costly









(Harvard Mark I )





Computer science First Class Lecture 1













EVI DAC ENI AC
3-2 second Generation 1953-1959
Then invention of the transistor in 1947 as a revolution in semi conductor
technology it was a small metallic .This generation began in 1953 with
(IBM 7090)also a major breakthrough was the Operating System (O.S)
and data Processing was started in many types (Inter active, Time shear
real time) , now the power requirement was reduced and the speed had
increased and also to compare that 1stb generations :
1- size was small
2- require Less power
3- Speed of operations is relatively
4- Portable & robust
5- No initialization time is required
6- less Heat is generated
7- cost is less
8- More reliable and less prone to faults
During this period some other high level language were developed
1. cobol (Common Business Oriented Language) it was design for
commercial & Business application
2. Basic (Beginners all purpose Symbolic Instruction Code) for all
tasks
3. PL/1 (Programming Language 1) a multi purpose language in
which used for (Scientific Computing, Business)





Computer science First Class Lecture 1
2-3 third Generation1959-1969
This generation began in 1959 with the production of the first computer
for commercial use (pdp8) with the use of Integrated Circuit (IC) of
silicon chips size 1/16
th
in
2
in which led to deferent types from main
frames( IBM 360) to mini computers & The features of this generation
was
1- size was small as group of transistors by a single IC
2- Portable & Handy
3- work in a higher speed 0.000000009 sec
4- Robust & reliable
5- it need less power
6- cost are low
the programming language developed during this period were
1.RPG (Report Program Genration) to change from punched cards to
programs
2.ALGOL(ALGOrithm Language) to represent Algorithm










Ppd8










IBM 360

Computer science First Class Lecture 1
2-4 Fourth Generation(1971-1981)
This generation began in 1971 example (NEC,MSX) with the use
of More powerful IC named (S.S.I) Small Scale Integration then
(M.S.I) Medium Scale Integration then (L.S,I) Large Scale
Integration and Then (V.L.S.I) Very Large Scale Integration which
led to invention of a microchip by Motorola Personal computers &
The features of this generation was
1- Very Small in size & weight
2- a better storage capacity compared with other generations
3- it is a multi-Purpose computer to do several task at the same time
4- Very Powerful in Mathematical Calculations & data Processing
5- Very fast
6- Need a little power
7- Reliable in true sense
8- Chip set among all generations of computer









During this period application software were developed and High level
programming language
1.PASCAL it was done by a swiss computer scientist
2.ADA for powerful programming
3.C it was done in bell laboratory
4.Structure Query Language (SQL) like Oracle











Computer science First Class Lecture 1
2-4 Fifth Generation (1981- )
This generation began in 1981 with (IBM XT & AT ) with the use of
Multi-integrated circuits in which led to more development in Personal
computers ( Lap Tops)& The features of this generation was
1- the size was very small
2- a better storage capacity compared with other generations
3- a better programming & software than 4
th
generations works in
various Felids
4- more faster than other generation
5- it does not need large space & ventilation
6- less cost than other generations
7- the use of artificial intelligence (AI) in factories
8- more application in the felids of nuclear energy & Space






Lecture 2 Computer science 1
st
class
COMPUTER ARCHITECT
The definition of computer
Computer is device formed of electronic circuits, electronic cards &
Micro- processor to perform exact calculations & Engineering,
Numerical& Logical Analysis faster than man
Another definition of computer
Computer is device formed of input Devices to process problem &
commands in central processing units to get data that reaches user by an
output device,
Computer types
1-Digital Computer: which mostly use in all types
2-Analog Computer: in which it deals with properties (voltage,
temperatures)
3-Hybrid Computers: it is mix of the analog & digital computer

Digital Computer Types
1. Micro Computer
2. Mini Computer
3. Mainframe computer
4. Super computer

Micro Computer Types
1-PC in which it has no hard disk
2-PC/XT in which it has single user
3-PC/AT in which it have both single & multi-user
PC/AT types
1. Desktop
2. Laptop
3. Palm Top
Computer properties
Computers properties are
1- Accurse :to reduces error to the least through data
2- Speed : to be fast in solving difficult problems
3- Storage : the ability to store data in memory
4- Cost: Must be at lowest cost




]
Lecture 2 Computer science 1
st
class
Computer Architect
Computer consist of
1. Hardware
2. Software
1-Hardware
Hardware functions
1- Inputting data & program through input devices
2- Saving data & programs in storage device
3- Handling data by applying program commands in the central
processing units
4- Showing results to user by output device
Hardware consist of
1- Input devices
2- Central processing unit (CPU)
3- Output devices
4- Storage Unit
1-1I nput devices
It's the devices that enters data & command to the computer to the
CPU for example (Keyboard, mouse, scanner, J oy pad, touching pen,
Electronic board, digitizer)
1-keyboard: a device contain keys a bout 102 represent letters &
numbers in addition to a special commands
2-mouse : a device resemble the mouse contain 3 buttons and a
scroll it works in the appearance of cursor, moving the cursor to an icon
and clicking on it by any buttons
3-scanner : scanner is an input device that insert photograph
pictures into the computer , there are two types on scanner the other type
of scanner is (OCR) it can transfer documents contain text to word
processing text
4-touching pen : This type is used by engineers The pen draws on
screen object it sends pluses to the computer
5-Electronic board: This type is also used by engineers the pen
draws on board object it sends pluses to the computer
6-digitizer : This type is also in engineering application it
resemble the mouse but with a lens The lens moves on special board
around the object it sends singles to the computer
1-4 Output devices : these are devices that show results to users
There are two types of output device soft Copy For example(Monitor)&
Hard Copy for example (Printer ,Plotter)
1-monitors:it is an output device that shows data & graphics on screen
resolution of screen is adjusted through a video adapter that controls
resolutions of the images
Lecture 2 Computer science 1
st
class
2-Printers: in which results are shown on papers printers are dot matrix
Printers letter quality printers, laser printers, ink jet printers, laser jet
printers
Lesar printers Dot matrix, letter quality
1. Less noise 1. very noise
2. High resolution 2. Low reslution
3. Faster 3. Slow
4. Paper quantity more 4. Quantity less

3-Plotters:these devices are used to show engineering drawing on large
size papers objects are drawn by a number of pens in different colors
Communication Devices
There are devices to connect computer to network either by
1- Through cards that links computer by telephone lines to network
(modems)
2- Through cards that link to wireless station Via Antenna network
(LAN Cards)

1-2Central Processing Units (CPU)
This is the most important unit in the computer ,the data that entered
through input devices is processed there it contain and it also executes
program
1-Arthmitic & Logical Unit (ALU) :this unit performs calculations &
Analysis Numerically & logically it takes decisions draw comparison
simple & complicated it work due to digital systems
2-Control Unit :this unit performs controls processing organizing data
input & output & organizing the process on the other units .
3-Memory unit: this unit temporarily stores program while it worked and
data ,it contain cells of storage its Known As Random Access Memory
(RAM). it is a volatile memory (ie it losses what contains when electrical
power off)
1-3 Storage Device : this unit stores program while it does not work
or data it is Known As Read Only Memory (ROM) , storage capacity is
measured By Bytes it is a volatile memory (ie it does not losses what
contains when electrical power off)
1 byte =8 bit
1 kilo byte =1024 byte
1 mega byte =1024 kilo byte
1 giga byte=1024 Mega Byte
1 tetra Byte =1024 giga byte
There are two types of storage devices

Lecture 2 Computer science 1
st
class
1- primary storage device : Hard disk
Hard disk: hard disk is non removable disk drive assembly with a built in
data storage ,data are stored on magnetized aluminum surface in which
are vertically stacked positioned ,data are transferred through hard disk
head , the hard disk drive are sealed so that the internal components are
not exposed to dust ,hair ,smoke & dirt , maximum storage is 500 Gb
2-secondry Storage Devices : (Floppy , CD-ROM ,DVD,
Flash Memory )
The storage devices are connected to computer through
devices(peripheral hardware) these are called drivers the disk are inserted
into drivers to enable to store data through hard disk, the process of
transferring data between computer & disks are called reading and
writing the computer can write data to disk through RAM ,the types are
1- Floppy disk : a magnetic disk made of silicon 3.5 inch diameter
1.44 Mb of storage
2- Compact Disk (CD ROM ): a disk made of composite material disk
,data are written through burning from a laser cell 700 Mb storage the
data can not b e erased
3- Re-writable Disk (CD-RW): a disk made of composite material disk
,data are written through burning from a laser cell 700 Mb storage the
data can be erased
4- Digital varsity disk (DVD) : a disk made of composite material disk
,data are written digitally through burning from a laser cell 8.4 Gb is
maximum storage the can not be erased
5- Re-Writable Digital varsity disk (DVD-RW ):a disk made of
composite material disk ,data are written digitally through burning
from a laser cell 4.7 Gb are the maximum storage the data can be
erased
6- Flash memory: these are sticks connected to computer through ports
called universal serial bus (USB)data are written through these ports
and data can be erased from the stick 8 Gb are maximum storage
7- Blue ray disk : this a disk storage capacity 21.4 Gb data are written
through a new laser technology
Computer Advantage
1.Speed
2.Accurcy
3. Memory Capacity
4.Absence Of Monotony
Computer Disadvantage
1.No IQ
2.No Instance or Emotions
1
st
classSoftware LectureThree

Software
This term means all programs installed in the computer, there are two
types of software
1 System software
System means a lot of devices which work togeather to do one or more
task at time so tor run a computer all hardnware and software and
personals will work togeather so system software are a set of program
routines and procedures which are needed by computer system it self to
run the process ,to control the computer but are not needed by user
directily but they are intirely needed by the computer In which they are
divided into
The main task of system software are
1 memory Management : at the time of writing program we assign data to
different variables these data are stored in memory but in most cases this
means the the control of where the data is stored and this type of
management is done by system software .
2 to control I/O devices & Peripherals : at the time of execution of any
program system soft directly control the operation of CPU in which to
control the I/O devices like controlling the printer or CD-ROM
3 J ob Scheduling :means the decisions taken by the computer as to the
task will come first & what will come next job priority are basically so
system is needed
System software are classified into
1 -Operation system: it do the task of memory management, input- output
Unit control , job scheduling it is also do spooling method (I e storing
data in a intermediate memory (Buffer memory) to make high speed
data communication ) the major task of operating System
1.to control the job of execution of the user for both single user and multi
user
2.I/O device management and spooling
1
st
classSoftware LectureThree

3.memory management
4.utilization Management (a method by which computer keep track of
computer access)
Operating system type
1-single user: it is a simple one computer system for one user such as
windows
2-multi user : these systems for many computers & users it executes
many applications, it divides memory & resources so can many user work
3- time share: these system are suitable for various computer from main
frame to personal computers such as LINX & UNIX
4-real time: a very fast operating system because it deals with a very fast
input & out put cases application such as electrical power plant , oil
refinery , nuclear reactors , military
Advantage s of Operating System
1. which are systems programs used to perform routine tasks such as
sorting data, or copying disk files into magnetic tape or other storage
device for back-up.
2. It also supports language translators which are systems programs that
translate the high-level languages to friachine-level languages It acts
as the interface between the users and the computer hardware,
checking and interpreting the users commands, and making the
machine execute them.
3. It manages all computer resources like CPU, primary memory,
input7output devices etc. required for efficient functioning, and
controls all input-output functions.
4. It loads programs from secondary storage devices into the main
memory of the computer, and transfers data between main memory
and peripherals, during program execution.
5. It prints messages for the programmer or operator regarding the status
of the program, and handles requests for input/output from the
executing programs.
6. It monitors the activities of users (in a multi-programming and time-
sharing environment) and provides information as to who are using
the system, for how long, what data and resources are being used, etc.
This can be very important for security purposes.
1
st
classSoftware LectureThree

7. It schedules the slices of time to be allocated to each in a time-shar
environment.
ing
8. It is responsible for memory management, i.e. it keeps track of what is
where in the computer's RAM, moves around data and program in the
computer's memory, and protects the programs, as well as itself, from
overlapping and crashing.
9. It performs data management routines like creating new files,
changing files, merging or re-organizing existing files, and extracting
required data items from them, and so on.
10. It helps use utility programs. Booting is the process by which the O.S.
is loaded into the computer's RAM.


Why we need operating system
1. lost time between starting & ending program
2. variation between input & output device & the CPU & storage
devices
3. the excess human intervention when errors occur or software need
to un ready data
Selection of operating system
1. Computer hardware & design
2. Application on the computer
3. Computer Performance
4. Type of input & output device connected to computer
2- compiler: these programs translated from the ordinary language to a
low level language which can be
3-Utility Programs: these are actually used frequently by the user and in a
type of system software the task include
1. Sorting Records
2. Copying file(s) from one disk to another
3. File merging
4. File manipulations, sorting
5. Formatting of disk and many other
6. Printing the memory contents
1
st
classSoftware LectureThree

2 Application software : it is a set of software which are required by the
computer any task by user so any software designed to perform specific
task is called that term the software package are for data analysis , data
storage , text manipulating and word process and program there are
hundreds of application but the most known are
1-Electronic Spread sheet : it is an on screen data manipulation of
language of acts where data are stored , computation and results are
displayed on screen with graphical representation (MS Excel)
2-Word processing are mainpulaions of language or text this enable user
to crate edit store delete print text and operate under over all control of
some OS (MS Word)
3- Engineering Application: it is on screen graphical engineering
Drafting or design the result is shown on screen (AutoCAD, )
4-Desk top Publishing : it is processing of publishing merging picture &
Text in which used for publishing books and journals ( Corel Draw , MS
Publisher)
5- Data Base it a system which consist of records that each reciord
contain felids each field contain an information (IE MS Accesses )
File
File is a chain of data & information that shares a specific characteristic
in certain way that can be handled by computer ,meaning that any
software ,Files are sorted in certain manner ,it need a space depending on
it size , each file have a name ,extension, location & properties .File has a
name( 11 characters) & extension distinguishes the file type -see table 1-
(mostly 3 characters), characters means (Letters a-z, numbers 0-9
,symbols(@#$%&)) some symbols can not be used example
(!?<>{}[]:*_+=?-/), files are stored in hard disk, floppy disk it can not
be stored in RAM , it stored separately or in folders , folder can contain
sub folders & files , but files can not contain folders in it they are
arranged in directory called root directory


1
st
classSoftware LectureThree

File management
File management means copying moving deleting renaming & moving
files
Extensions Type
Doc Word
Dwg AUTOCAD
PDF ADDOBE ACCROBAT
DLL WINDOWS SYSTEM
WAV AUDIO
J PG PICTURE




c:\

WINDOWS PROGRAM
FILES
VCDCutter

Microsoft
Office
AutoCAD


Excel
Files


Word
folders


PowerPoint


Acsess


1
st
classSoftware LectureThree

Minimum Requirements
This term means the least speciation of hardware and software that
require to start the software from memory , video display , processor
&disk space so that it can run
Optimal Requirements
This term means the best speciation of hardware and software that
require to start the software from memory , video display , processor
&disk space so that software perform as it best

WI NDOWS
Basics of Windows
Windows is a software program through which yon can interact with
your computer moit easily. With the use of Windows, you can make your
jobs with computer easier and easier as you proceed through the
advancement of windows and finally leading to Windows 95 Windows 98
respectively, which are basically full fledged operating systems.
If we see at the history of development of Windows, we can see that
the concept of windows has been conceived by the Microsoft Corporation
Inc. at the November 1985. They fust developed the Windows version 1.
But due to some drawbacks and limitations, it was actualh not successful.
Windows was not acceptable to the computer people until its version 3.1
arrived at the late eighties. From this version of Windows, it was a
complete success and became very popular. Later they released their
version 3.11, a Windows workgroup version. But these windows were not
full fledged operating system. Actually in these system DOS worked at
the background and the roll of Windows was to act as an interface system
between the operating system and the user.
After a few years Microsoft Corporation launched their product
Windows95. This was actually a turning point, because from Windows95,
it became a complete operating system Any PC range of computer can
run directly under Windows95 as the operating system without using
DOS.
Windows became more and more powerful and rich with the built-in
facilities. The newer versions of Windows like Windows97, Windows98
etc. came in the market successively and became more and more popular.
They have launched their latest product Win NT and Windows XP,
network version of Windows and became very popular to the computer
network users within a short period.
1
st
classSoftware LectureThree

Though DOS is a very powerful operating system, it has got some
limitation too. First limitation of DOS is, it is basically a single user
operating system, i.e. more than one user can not work with a single
computer at a time, using DOS. So if DOS is used in network
environment, some types of additional hardware and software support
will be required to make it possible. This is called 'DOS-LAN', where
'LAN' means 'Local Area Network'. There are some other I limitations.
The other main problem is, you have to remember all the commands
separately for each and every DOS based software. So if you work with
the word processor package using | DOS, you have to remember all the
related and relevant commands. Similarly for any database or spreadsheet
application package requires another full set of commands to remember.
Normally there is no similarity of the commands of the DOS based
software. So you have to remember all the necessary commands of all
related software. Another drawback of DOS based system is, normally
you can not share or exchange data between the DOS based systems. For
example, if you want to highlight some portion of a spreadsheet in any
document using word processors, you have to follow a long and elaborate
process to do it, if it is possible. These type of limitations is overcome
using WINDOW based system.
Window was basically and initially developed not as an operating system,
but to complement DOS to avoid its limitations. The first successful
version of Windows is its version 3.1, which was updated to version 3.11
to work in work group environment. Windows 3.1 and Windows5.11 was
not an operating system but it requires to have DOS already installed on
the computer in order to run. Thus windows replaces the DOS interfaces
with an easy to use interactive environment to work more smoothly and
effectively in most user friendly environment. This version of windows
have been updated successively with the Windows 95, Windows 97.
Windows 98 etc. From Windows 95, it became a full fledged operating
system used in personal computers. The Windows has been developed by
Microsoft Inc., USA. Windows first version has came in the market in the
year 1985 but that was not so popular due to some limitations. The
updated versions of 1.2,2.1 and 3.0 has came in the market in 1987 and in
1990 respectively, but that were not popular too. Popularity has first came
for the version 3.1 which came in the year 1992. The windows 95 was
launched in August '95 and was the first pc based 32 bit operating system
of the world. The more and more updated version of windows are
Windows'98 and Windows NT which are used now a days in almost all
pc based machines.
The main features of Windows are:
1
st
classSoftware LectureThree

Graphical User I nterface (GUI ) facility
In windows environment you do not have to write the commands to
execute, instead of that you just select the object by a pointing
device like a mouse from a group of small pictures on the screen,
called 'icons'. J ust by clicking at the proper icon, you can execute
a command. So you do not have to remember and write the
commands with all its options and syntaxes.
Simitar set of commands The software used in windows
environment are almost the same set of commands. So in this
system you don't have to remember all the commands for all the
software.



Dynamic Data Exchange (DDE) facility
In windows environment we can share and exchange data from any
software very easily. This is frequently done in different
applications.
Object Linking and Embedding (OLE) facility
This is another area where we can select any object from any
window based application and embed the part to any other
applications through the built in 'clipboard' facility of window.
Clipboard is a temporary common platform through which we can
do it. Even linking can be done between two objects in such a way
so that updation or change to any object updates or changes the
linked object automatically.
Open Data Base Connectivity (ODBC) Window based database
application packages are so designed that database created bv any
application can be used and updated by any other applications.
This facility helps the programmers to built more robust and
versatile programs or packages easily.
Multitasking facility
In windows environment we can employ multitasking facility. So
using this system you can go on with any task, while another task
like background printing will be continued parallely. This was
made possible by partitioning the screen into multiple windows,
where each window will be associated with a different window
based program.
Multi user operating system
The advanced version of windows like Windows NT, operates on
multi environment. In this system the system provides multiple
users to work simultaneo with the computer but from different
terminals.
Easy user interfaces
1
st
classSoftware LectureThree

Interface means a link between two incompatible different systems
to work togc In windows environment it is done very efficiently.
Better resource management
One of the main task of the operating system is the resource
management. Win based system manages the resources in more
better way.
Better utilities and accessories facility
A group of highly useful utility and accessory programs are
provided with the win system for very useful purposes.
Plug and play facility
In Windows 95 and in advanced versions a unique facility is
provided. This is as 'Plug and play' arrangement. If this system is
present in the operating system, no installation or other formalities
will not be required if addition or alterati made for the attached
devices like CD driver, sound systems, video systems etc. term
'plug and play' means you can just play it after plugging into the
system.
On line help facility
Windows has got a powerful on line help facility by which the user
can get helpw working. At any time you can choose the 'Help'
menu to get help.
Advantages of using Windows
A common question may arise to any first time user of Windows that
whyshouldIWindows?It is a very common question to the first time
users of Windows. So to get ad cut conception we should discuss here
the advantages and features of Windows.
There are many advantages of Windows. These are:
User friendliness with GUI facility
In case of Windows you do not have to remember and write the
commands all along. Here you can click to an icon, a menu or at
any control point to do some specific jobs. The GUI (Graphics
User Interface) facility provides you the option to select and click
at the small pictures or symbols on screen (known as icon) to do
any meaningful So using this, you can eliminate to memorize all
the related commands to use.
Here we will discuss on Windows 95 and Windows 98 respectively in
brief.
Windows Desktop
Windows Desktop means the view on the monitor which will be
available to you just after loading Windows. A sample of such
view is given below for Windows 98 version. The screen may not
1
st
classSoftware LectureThree

look alike with your or other computer's Windows background
picture. The icons may be different, the color schemes may also
be different. But the basic scheme will remain same

In the menu shown, the items displayed on the leftmost menu will be
same to all th computers running under Windows 98. But at the Program
sub menu what you see - mayt different to other computers. Because it
will show the installed programs in that particul computer. Of course
there are some common programs Accessories, I nternet Explorer, M
DOS Prompt etc which will be common to all the computers. Because
these are the residenti programs of the Windows system.
In order to access all the menus, to select and to activate the essential
device is Mow Without using a good quality of mouse it will be almost
impossible to do all these things. So us have a look on Mouse first.
The Mouse
You can perform any function in Windows using either the mouse or
the keyboard. Howe it is recommended that you use the mouse as your
handy tool which has so far gained unive acceptance.
Some short descriptions are given below:
Pointing: When you move your mouse on a smooth desk the cursor
pointer mc accordingly on the screen. This is called pointing.
Clicking: Pressing the left mouse button is called clicking.
Double Clicking: To initiate program or parts of program in Windows
you have to [ the left button twice very quickly which is known as double
clicking.
Right Clicking: Right-clicking means to the pressing of the right
mouse button. I clicking is needed more frequently in more advanced
versions of windows.
Start up windows
As already mentioned, program files and other resources are
represented graphica Windows and are generally accessed by the mouse.
Here the Windows desktop pla important role. This refers to the graphical
items that appears on your computer screen you start up your machine.
The term desktop is synonymous to the desk of a busy executive at an
office wl arranged properly with files, pens, paperweights, books and
other necessary equiprr per his/her desire so that the work can go
smoothly. Similarly the Windows desl arranged properly so that the user
can work more enthusiastically and exploit its f( effortlessly.

In each and every windows there are some common components
present components are used to do different tasks more easily and
1
st
classSoftware LectureThree

accurately. These are k Windows components. Some of the common
Windows components are discussec in brief.

To make a copy of a disk
In My Computer or in the right side of Windows Explorer, click the
icon for the disk want to copy. After that, on the File menu, click Copy
Disk. In Copy from, click the drive want to copy from. In Copy to,
click the drive you want to copy to. After that click at Start.
To make such a copy, you can use the same drive for both disks. But
the condition to maintained is, the disks must be of the same type.
Remember that, any existing information on the disk you copy will be
deleted.
To move files by dragging instead of using menus
In My Computer or Windows Explorer, find the file or folder you
want to move, sure the place you want to drag the file or folder to is
visible. After that drag the file or fo to the destination.
1. If you right-click to drag, a menu appears with the available opti
2. If you dra
ons.
g a file or a folder to a location on the same disk, it will be
time by
To make a copy of a disk
moved. If drag it to another disk, it will be copied.
3. You can create a copy of a file and move it at the same
pressing CTRLw
L
you drag the file to a new location.


ight side of Windows Explorer, click the icon for
the
an use the same drive for both disks. But the
con
py will be deleted.
To move f
In My Computer or in the r
disk want to copy. After that, on the File menu, click Copy Disk. In Copy
from, click the drive want to copy from. In Copy to, click the drive you want to
copy to. After that click at Start.
To make such a copy, you c
dition to maintained is, the disks must be of the same type.
Remember that, any existing information on the disk you co
iles by dragging instead of using menus
In My Computer or Windows Explorer, find the file or folder you want to
move, sure the place you want to drag the file or folder to is visible. After that
drag the file or fo to the destination.
1
st
classSoftware LectureThree

If you right-click to drag, a menu appears with the available options.
If you drag a file or a folder to a location on the same disk, it will be
moved. If drag it to another disk, it will be copied.
g

lder to is visible.

.
on the same disk, it will be
moved. If you drag it to another disk, it will be copied.
g
You can create a copy of a file and move it at the same time by pressin
CTRLw
L
you drag the file to a new location.
To move files by dragging instead of using menus
1. In My Computer or Windows Explorer, find the fde or folder you want to
move.
2. Make sure the place you want to drag the file or fo
3. Drag the file or folder to the destination.
If you right-click to drag, a menu appears with the available options
If you drag a file or a folder to a location
You can create a copy of a file and move it at the same time by pressin
CTRL while you drag the file to a new location.
To save a file with a different name or format
1. On the File menu of the programyou are working in, click Save As.
2. Specify the name or format in which you want to save the file. If the file
r format, that version will was previously saved with a different name o
remain unchanged
To send a file or folder to a disk
1. If you are copying a file or folder to a floppy disk, insert the disk in the
disk drive.
2. In My Computer or Windows Explorer, click the file or folder you want
ile menu, point to Send To, and then click the drive you want to
, click the folder.
other document
to copy.
On the F
copy the file or folder to.To select a folder in the left pane of Windows
Explorer
Sending a file or folder to a disk sends a copy. The original file or folder
remains in the original location.
To copy information into an

want to select.
1. In the document that contains the information you want to copy, drag the
pointer over the information you
1
st
classSoftware LectureThree

2. On the Edit menu, click Copy.
3. In the document where you want the information to appear, click the
place where you want to put the information.
4. On the Edit menu, click Paste.
To create a folder
1. Click the drive in Windows Explorer where you want to create the new
enu, point to New, and then click
NTER.
lick the folder and then
steps two and three above.


folder.
2. On the File m
Folder. The new folder appears with a temporary
name.
3. Type a name for the new folder, and then press E
If you want to create a new folder within a folder, c
follow

Data Processing
Booting
It is the starting & switching on of a computer by giving a beeb sound ,
the CPU get informed from that sound that all proper voltage are on
available to proper place it comes from power good signal
The word boot came from the word boots strap (ie pulling self by it own
boot strap ) this a small program in (ROM-BIOS)
Booting has two types
1 warm booting : when computer "Hangs" at the time of working
2 cold booting : when the computer is started it's start what is cold
booting
Data :The term data means the raw material which it transformed to a set
of information
I nformation: this term means a set of data is arranged & presented in
meaningful way to the user who receive it
Data Processing : is a process in which raw material (data) is transferred
to a useful Product (Information) the word data is from Datum(Latin) it
means a set of fact which basically mens nothing It is used for singular &
Plural
Data means
a. Different type of information in range
b. Different Level of information
Range of information means
1.stratigic (long range planning)
2.Tactical( short range planning)
3. Operational
I nformation level
1.international information
2.national information
3.cooporate information
4.department information
5. individual information
Types of data
1- Physical data : it is the actual structure of data storage media when we
store data the way it is stored known as physical storage
2-Logical Data :it is the way the data seen by the programmer in other
words it is the user oriented ways of describing & understanding data
Data processing with computer system
Data capture means to get a data from available medium.the data may
have been collected from different sources .so the method of data capture
will be obtained different from deferent medium and system these method
are :
1 data capture from (key-to- storage): a very old stage of capturing data
used in many form using off line data entry system in which data were
key into temporary medium in which the next stage was the stored
medium (CD ,DVD ,Flash RAM)
2.data capture from scanner there are two type of scanner Optical ,
Magnetic sensor type the capture system are
a.OMR(Optical Mark Recognition System) by scanning over the
document by light scanning
b.OCR(Optical Character Recognition System) by scanning over the
document by an electron beam .
c.MICR (Magnetic Ink Character Recognition System )data are entered
by using magnatic ink system
3. Direct Data entry through intelligent terminal data in which data are
entered by Keyboard in most of modern systemthe computer used in
networking are called terminal there are three type of terminal.
a. dumb terminal
b. smart terminal
c. intelligent terminal
data type are classified as
1. Alphabetic
2. Alphanumerical
3. Numeric ( forms of binary system) ASCII
Graphical Processing
In different occasions it is preferred to present output of process in
graphical form rather a tubular output .Graphical illustrations of numeric
compounds and results are show in a bar chart , line graph ,data fed into
computer and processed through into graphical data and then set on a day
of are used for graphical presention output.
Use of computer graphics
Computer based graphics improves productivity and quality for
analysis and decision ng. Computer Aided Design (CAD) is the main use
of graphics on engineering applications, as structural engineering (Civil),
architectural (Planing), Hardware circuit design, Printed it Board (PCB)
design are the main uses of computer graphics. The justification for using
uter graphics rather than tabular reports are improved productive and
improved quality alysis or decision making. For hard copes, plotters and
some type of printers are used.

Types of data
There are different sets of data available which are used in different
occasions. A careful observation regarding the types of data can help us
to design a perfect database system. Some type of data never changes,
some changes occasionally and some type of data changes frequently. So
let us have a look on different types of data.
Static data item
These are non changeable type of data in nature and their values
does not change with respect to time. These are very common type
of data in nature. Examples of these type data are, account
numbers, date of birth etc.
Changeable data items
A changeable data item is one that remains unaltered for some span
of time and is not automatically changed at regular intervals, e.g. a
tax code can not change regularly but it may change occasionally
when the tax payers financial status changes. Marital status of a
person is also an example of it. Because marital status of a person
may change occasionally, but it does not change regularly.
Dynamic data items
These type of data is changed frequently. It can expect to be
updated at regular intervals as a consequences of activities taking
place. Examples of these type of data are stock levels in an
inventory system, balance present in a bank account etc.
Data processing system
Now we will discuss the data processing system in brief, its essential
features, common techniques used and on other related items.
The term data pr ocessi ng means the process using which any raw
sets of data can be converted to a meaningful information. If we consider
the raw sets of data as raw materials then the derived information from
it may be considered as the finished product.
The overall data processing system can be conceived of a system
consisting of three major area. These are:
Capturing the input data
Manipulating data and
Prepare the output result
Capturing the input data
It is a simple matter to understand that before processing data, it must
be captured properly. It must be available at the processing terminal at the
time of processing.
The sets of data may be available in different forms. For example, it
may be available in hard copy form, i.e. in printed form. So the data
capturing unit should be capable of capturing data from this medium.
Similarly, if the data is available in computer storage form, the data
capturing unit must be capable of capturing those sets of data.
The data capturing unit must be reliable, accurate and should have a
broad bandwidth to capture all sets of data faithfully, accurately and
reliably.
The common computerized data capturing units are - keyboard,
automated teller machines, optical mark readers, optical character
readers, magnetic ink character recognition unit, bar code reader etc.
Manipulating data
This is one of the main area of data processing. Data manipulation part
covers a wide range of activities. The major areas of the data
manipulation job has got a set of tasks involved. These are:
Classifying data
The first part of this area is the data validation part. Computer is
a machine and is also known as GIGO (Garbage In Garbage Out)
machine. So, if any kind of garbage is entered as data, it will
produce garbage output. So after capturing data and before sending
it to the processing unit, the validity of the data is first checked. If it
is valid, it is passed to the next level of processing.
In this area, the other main task is - to form the grouping of data.
Similar type of data are arranged in a group which helps for easy
processing. Data may also be classified and grouped by -
numerical, alphanumerical and alphabetic type.
Calculating data
In the processing steps, arithmetic calculations may also be
required as part of the data manipulation activity.
Sorting of data
Sorting means to re-arrange the existing sets of data to some
meaningful order. In some applications it may also be required to
sort data. Sorting may be required in ascending, or descending in
case of numeric data. For alphabetic data it may be of alphabetic or
reverse alphabetic type.
Summarizing result
It is a common practice to produce a summarize result than that of
producing an elaborated report. So, if a summarized report is
required, it is to be developed.
These are the steps involved in manipulating of data.
Preperation of the output result
Once the data capturing and data manipulation process are completed,
the next important step, i.e. the preparation of the result starts.
In this area, two major sub area exists. These are:
Storing and retrieving result
This part is often required in some type of data processing systems.
Here, the result is not published instantly - rather stored in a media.
It is published when it is asked for.
Communication and reproduction of result
It is that part of the data processing activity where, the result is sent
to some other location where it is asked for. The data may be
transmitted through copper cable, LAN and INTRANET
connection. It may also use INTERNET connection to send data at
a very large geographical distance.

1
st
Class Programmingcomputer lectno5

Programming the computer
Programming the computer consists in producing a series of commands
that the computer can understand in order to produce a desired action.
Typical actions that electronic computers can
perform are input and output of data, data processing, and control of
interfaces or other devices.
At the most basic level, an electronic computer simply interprets voltage
pulses as data or commands. From a mathematical point of view, the
basic processing of information by the computer consists in the
manipulation and interpretation of binary digits or bits (i.e., zeros and
ones). At this level, thus, commands are represented by strings of zeros
and ones.
Communicating with the computer at its most basic level takes place
through the use of binary or machine language. Trying to type in these
binary commands for computer programming
would be overwhelmingly slow and tedious. The use of human-like
language significantly facilitates the programming of computers.
The next level of computer language is referred to as assembly or
assembler language. It consists of simple commands like ADD, STORE,
RECALL, etc., followed by memory addresses
within the computer. Although an improvement over machine language,
assembly or assembler languages are still quite primitive. High-level
languages such as FORTRAN 90, C++, C#, J ava, Visual Basic 6.0, etc.,
with their human-language-like syntaxes (typically, English) facilitate the
programming of the computer for most human programmers.
Each one of these high-level languages possesses its own syntaxes or
language rules. Violation of the syntaxes of a specific language will result
in failure of programming the computer.
Programs in high-level languages are typically typed into the computer in
the form of text files, and then run through a special program referred to
as an interpreter or a compiler. The interpreter or compiler translates the
programs into machine language, the basic language that all computers
understand.







1
st
Class Programmingcomputer lectno5
Tools for programming
Typically, to write a program, the programmer starts by selecting
or designing an algorithm,i.e., a plan for performing the action
required from the computer. An algorithm can be simply
a series of sequential steps that the computer must perform to
produce a result. For example,if we intent to use the computer
to add two numbers (a relatively simple operation, mind you),
we can describe the corresponding algorithm in words as follows:
input the first number, input the second number, add the two
numbers, store the resulting number into a memory location,
show the number in the screen.
Algorithm
Algorithm are logical sequence to steps or rules which solves a
complex problem Mathematical, Statistical & logical it's the frist
step for programmer to solve problems
Algorithm types
1-logical
2-Numircal
Algorithm properties
1. A clear one
2. Logical sequence
3. Take all options
4. The use of flow charts
Numerical Algorithm
Algorithm are logical sequence to steps or rules which solves a
Mathematical problem
logical Algorithm
Algorithm are logical sequence to steps or rules which solves a
Logical problem



1
st
Class Programmingcomputer lectno5

Flow charts
An algorithm can be presented or described using a
flowchart. A flowchart is simply a collection of geometric
figures connected by arrows that illustrate the flow of
the algorithmic process.
The geometric figures contain information in the form of
commands or mathematical operations describing the
algorithm and the arrows indicate the sequence of steps
in the algorithm. The following flowchart describes the
algorithm written above for the addition of two numbers.







This flowchart is quite detailed for a simple operation. A
more simplified version is shown below:











1
st
Class Programmingcomputer lectno5
The basic components of a flowchart are the following geometric
shapes,plus the arrows





In the previous example we used all but the decision shape.
We will show examples of decision algorithms later
Pseudo-code
While flowcharts are useful guides for describing an algorithm,
producing a flowchart can become quite complicated,
particularly if done by hand. Also, modification of a hand-made
flowchart can be quite involved. Luckily, flowcharting software
are now available that can simplify the process. If one doesnt
want to get involved in producing a flowchart, one can
use another technique known as pseudo-code.
Pseudo-code simply means writing the algorithm in brief English-
like sentences that can be understood by any programmer. For
example, a pseudo-code corresponding to the algorithm
described in the flowchart shown earlier is presented next:
Start
Input a, b
a =b + c
Display c
End
Notice the use of the algorithmic sentence a ! b + c, in both the
flowchart and the
pseudo-code, to indicate that the addition of a and b is to be
stored in variable c.
This algorithmic sentence was translated in the Visual Basic 6.0
code as c = a + b because, in
that high-level language, the equal sign represents an assignment
operation (i.e., the value a+b is assigned, or stored into, c).
Since the equal sign (=) represents assignment in most high level
languages, it is possible to write the sentence n = n + 1. This
sentence, rather than representing an algebraic equality that will
result in the wrong result 0 = 1, indicates that the value
1
st
Class Programmingcomputer lectno5
contained in variable n is to be incremented by 1, and the
resulting value is to be stored into n.


Decision structure
A decision structure provides for an alternative path to the
program process flow based on whether a logical statement
is true or false. For example, suppose that you want to
evaluate the function
f x . =|x- 1|, if x >- 1
| x+1|,x if x<=-1
The flowchart to the right indicates the process flow of a
program that requests a value of x and evaluates y = f(x).
The diamond contains the logical statement that needs to
be checked to determine which path (T - true, or F - false)
to follow. Regardless of which path is followed from the
diamond, the control is returned to the display statement.
Notice that the input statement and the decision statement
form a sequence structure in this flowchart. As in this
example, the three types of structures under consideration
(sequence, decision, loop) do not appear alone, but two or
three are commonly combined in many algorithms.
start
input x
if x<-1 then
y |x+1|
else
y |x-1|
display x,y
end



















1
st
Class Programmingcomputer lectno5


Sequential structure
A sequential structure was used in the previous section to
illustrate the use of flowcharts.
Sequential structures have a single entry point and a single
output point, and consist of a number of steps executed one
after the other. Sequential structures can be useful in simple
operations such as the addition of two numbers as illustrated
earlier.
The following pseudo code illustrates a sequential structure
consisting of entering a number and evaluating a function given
by a single expression:

start
request x
calculate y = 3 sin(x)/(sin(x)+cos(x))
display x, y
end

Loop structure
A loop structure represents a repetition of a statement or
statements a finite number of times.
For example, suppose that you want to calculate the following
Summation The algorithm for the calculation is illustrated in the
flowchart shown below.

start
input n
Sn >0
k =0
do while ~(k>n)
k ! k + 1
Sn=Sn + 1/k
end loop
display n, Sn
end




1
st
Class Programmingcomputer lectno5






Notice that the loop structure is part of a sequence structure
and that it contains a decision structure within, thus, re-
emphasizing the fact that the three basic structures (sequence,
decision and loops) commonly appear together in many
algorithms.
Notice also that the loop structure requires an index variable, in
this case k, to control when the process will leave the loop.
The summation Sn and the index variable k are both initialized to
zero before the control is passed to the loop structure. The first
action within the loop structure is to increment the index variable k
by 1 (k !
k +1). Next, we check if the value of k has not grown beyond that of n
(k >n ?). I f k is still less than n, the control is passed to incrementing
the summation (Sn=Sn +1/k), and back to the first step in the loop.
The process is then repeated until the condition k>n is satisfied. At
this point, the control is passed on to reporting the results n, Sn.
The pseudo-code corresponding to the flowchart shown above is the
following:
start
input n
Sn= 0
k =0
do while ~(k>n)
k= k + 1
Sn=Sn + 1/k
end loop
display n, Sn
end
Notice that instead of translating the loop structure in the
flowchart with an if statement, we used the statement do while.
(Do-while statements are commonly available in most high-level
computer programming languages). Notice that a condition,
namely ~(k>n), is attached to the do while statement in the
pseudo-code. The statement is to be read as do (the
statements in the loop) while k is not larger than n.
After the condition in the loop structure is no longer satisfied,
i.e., when k>n, then the loop ends and the control
1
st
Class Programmingcomputer lectno5
Programming Languages
_Low-level Languages
_Assembly Languages (_MV 6, SUM)


.

_Symbolic operation codes are used to write
programs.
_Higher level but still arcaric.
_Also, can be proprietary
_Requires an assembler to translate the program
into machine code.
_High-level Languages
_"English-like" languages (_x = 6 )
_BASIC, PASCAL, FORTRAN, COBOL, C,C++,
J AVA
_Requires a compiler and an assembler to translate
the program.
_The compiler translates to assembly language.
_The assembler translates to machine language.

Programming
Programming the computer consists in producing a series of
commands that the computer can understand in order to produce
a desired action. Typical actions that electronic computers can
perform are input and output of data, data processing, and
control of interfaces or other devices.

Coding a program
The listing of a program written in a high-level language is also
referred to as code. For example, the code corresponding to the
flowchart, code are
1. command
2. text
3. constant & variables
4. Strings
5. Expression
6. equations & formulas
7. line number

Commands
There are also special functions called "commands" (also called
"instructions"). A "command" tells the QBasic interpreter to do
something.
The PRINT command tells the QBasic interpreter to print
something to the screen
Text
Are printing words or phrases in program it must proceed by
command Print & between cot mark ( "" )
Print "Ahmed"
If you press F5 then
Ahmed will appear on screen
constant
the are values are constant in program
X=10 that is a integer constant
X=10.5 that is real constant
Variable
A variable is a piece of data kept in the computer's memory (RAM).
The location of a variable in RAM is called the "address."
How a variable is stored in RAM
The following program prints the variable X to the screen:
print X















The following program prints the variable X to the screen:
print X
Since the variable hasn't been assigned a number, the value of
the variable is 0. So, the output of
the program is:
0
This next program sets X to 15, and then prints the variable:
X = 15
print X
This time, the output is:
15

Variables Are values unknown in the program ( inputs & output)
in which are processed in program there are two types
1. Numerical numbers
2. String Names it separated by $

Strings
There are certain types of data (or information) called "strings."
Strings contain a sequence of characters (letters, numbers, and
symbols) enclosed in quotation marks. For example, "Hello
World!" is a string.
The following are also strings:
"0123456789"
"This is a string"
"abc123"
"1 + 1 = 2"
"!@#$%^&*()"
Expressions
An expression is something the interpreter calculates (or
evaluates). Such as:
1 + 1 (returns 2)
100 - 47 (returns 53)
3 * 34 (returns 102)
80 / 4 (returns 20)
(100 * 3) + 56 (returns 356)
Equations & Functions
Computer has priority in applying mathematical equation on the
following
1. Between brackets ()
2. Power
3. Multiply & Division
4. Adding & subtraction
Mathematical Functions are in this table

No Function Description
1 Sin


2 Cos
3 Tan
4 Atn
5 log
6 exp
7 Sqr
8 Int
9 Fix
10 Abs
11 Deffn
Angles are in radians in basic to convert use correction
equation A=A*(3.14/180)
Characters :There 3 type of characters
1-numbers 0-9
2-Letters A-Z,a-z
3- special characters as in table below


1 +
2 -
3 *
4 /
5 ^
6
7 .
8 :
9 " "
10 ( )
11 $
12 <
13 = >
14 = <
15 <>
16 >
17 ;

QBasic interface
This chapter gives a brief overview of the QBasic interface.
The interface has the following features:
1. Window displaying the current program
2. Menu
3. Name of current program
4. Window to immediately execute a command
5. Status bar
6. Status of Caps Lock and Num Lock
7. Current line of cursor
8. Current column of cursor
QBasic interface
Current program
The current program is displayed in the middle of the screen, and covers most of the QBasic
interface.
Menu
The menu provides most of the operations for the QBasic editor. Such as opening a file, pasting
text, and searching for a string.
File
New - Clears the current program
Open - Loads a program from disk
Save - Saves the current program to disk
Save As - Saves the program, but under a different name
Print - Prints the selected text, current window, or entire program
Exit - Closes the QBasic interpreter
Edit
Cut - Removes the selected text and stores it in the clipboard
Copy - Copies the text instead of removing it
Paste - Adds the text in the clipboard to the current position of the cursor
Clear - Removes the text without storing it to the clipboard
New Sub - Enables you to create a new subroutine (see Subroutines and Functions)
New Function - Enables you to create a new function (see Subroutines and
Functions)
View
SUBs - Shows the list of current subroutines and functions (see Subroutines and
Functions)
Split - Displays the contents of the current program in two windows. If the window is
already split, this hides the second window (NOTE: The text in each window is
always the same, even if you alter the text in one window)
Output Screen - Shows the QBasic output screen.
Search
Find - Allows you to search for a string of text in the program
Repeat Last Find - Continues the previous search operation
Change - Replaces each instance of a string with another string
Run
Start - Executes the current program
Restart - Starts from the beginning
Continue - Continues execution at the current position
Debug
Step - Processes the next command
Procedure Step - Processes the next command, but does not show QBasic going
inside a subroutine or function
Trace On - Shows the command that is being executed while the program is running
Toggle Breakpoint - Sets or removes a breakpoint. Use this to have the QBasic
interpreter stop when it reaches a specified line in the program
Clear All Breakpoints - Removes all breakpoints in the program
Set Next Statement - Allows you to continue execution at the specified line
Options
Display - Enables you to change display colors, the number of spaces to use for
tabs, and whether or not scroll bars are visible
Help Path - The location of the QBASIC.HLP file
Syntax Checking - Allows you to have the QBasic editor check the syntax of your
program as you type
Help
Index - List of all QBasic commands, keywords, operators, etc.
Contents - The table of contents for QBasic help
Topic - Show help for a specific keyword
Using Help - Displays information on using QBasic help
About - Shows information about the QBasic interpreter
Name of current program
The file name of the current program is displayed near the top of the screen in the center. You
can change the name by selecting " Save As" on the " File" menu.
Immediately execute a command
QBasic provides a way to execute a command without running the current program. To do so,
select the bottom window (under " immedi ate" ) and enter a command, then press Enter.
Status bar
The status bar is at the bottom of the screen. It displays a short list commands
(<Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step>).
When you highlight an item on the menu, the status bar displays a short description of what the
item does.
Status of Caps Lock and Num Lock
If Caps Lock is set, a " C" is displayed on the right side of the status bar.
If Num Lock is set, an " N" is displayed on the right side of the status bar.
Current line
On the right side of the status bar, the current line of the cursor is displayed.
Current column
On the right side of the status bar, the current column of the cursor is displayed (immediately
after the current line).
Mathematics functions
QBasic provides several functions to do mathematical calculations. A few of them are discussed
here.
SQR
Use SQR to find the " square root" of a number.
PRI NT SQR( 1)
PRI NT SQR( 4)
PRI NT SQR( 9)
PRI NT SQR( 16)
PRI NT SQR( 25)
Output:
1
2
3
4
5
ABS
ABS returns the absolute value of a number. In other words, ABS converts a negative number to
a positive number (if you pass a positive number, ABS does nothing).
PRI NT ABS( 12)
PRI NT ABS( - 12)
Output:
12
12
COS, SIN, TAN, and ATN
You can do the following trigonometric functions in QBasic:
COS ( Cosi ne)
SI N ( Si ne)
TAN ( Tangent )
ATN ( Ar ct angent , i nver se of TAN)
Example:
CONST PI = 3. 141593
PRI NT COS( PI / 4)
PRI NT SI N( PI / 3)
PRI NT TAN( - PI / 2)
PRI NT ATN( TAN( - PI / 2) )
Output:
. 7071067
. 8660254
6137956
1. 570796 ( Same as PI / 2)
The IF and THEN commands
The I F and THEN commands are used to compare an expression and then perform some task
based on that expression.
x = 5
I F x = 5 THEN PRI NT " x equal s 5"
Since X does equal 5 in this case, the program outputs:
x equal s 5
Expression signs
You can also enter the following statements, instead of the equals sign:
x < 5 ( x i s l ess t han 5)
x > 5 ( x i s gr eat er t han 5)
Run the following:
x = 16
I F ( x > 5) THEN PRI NT " x i s gr eat er t han 5"
Output:
x i s gr eat er t han 5
You can also combine the signs like this:
x <= 5 ( x i s l ess t han or equal t o 5)
x >= 5 ( x i s gr eat er t han or equal t o 5)
x <> 5 ( x does not equal 5)
Run the following example:
CLS
x = 5
I F ( x >= 5) THEN PRI NT " x i s gr eat er t han or equal t o 5"
I F ( x <= 5) THEN PRI NT " x i s l ess t han or equal t o 5"
I F ( x <> 5) THEN PRI NT " x does not equal 5"
Output:
x i s gr eat er t han or equal t o 5
x i s l ess t han or equal t o 5
ELSE
Using the ELSE command, you can have the program perform a different action if the statement
is false.
x = 3
I F x = 5 THEN PRI NT " Yes" ELSE PRI NT " No"
Since X doesn't equal 5, the output is:
No
END IF
END I F allows you to have multiple commands after the I F. . . THEN statement, but they must
start on the line after the I F statement. END I F should appear right after the list of commands.
x = 5
I F ( x = 5) THEN
I NPUT a$
PRI NT a$
END I F
The following program uses ELSE with the END I F command:
x = 16
I F ( x = 5) THEN
I NPUT a$
PRI NT a$
ELSE
PRI NT x * 2
END I F
Output:
32
TIP: There is a way to have multipl e commands
after I F. . . THEN without using END I F. To do
so, place a colon between each command.
IF (x = 5) THEN INPUT a$: PRINT a$
ELSEIF
The ELSEI F command allows you to perform a secondary action if the first expression was false.
Unlike ELSE, this task is only performed if a specified statement is true.
x = 6
I F ( x = 5) THEN
PRI NT " St at ement 1 i s t r ue"
ELSEI F ( x = 6) THEN
PRI NT " St at ement 2 i s t r ue"
END I F
Output:
St at ement 2 i s t r ue
You can have multiple ELSEI F commands, along with ELSE.
x = 8
I F ( x = 5) THEN
PRI NT " St at ement 1 i s t r ue"
ELSEI F ( x = 6) THEN
PRI NT " St at ement 2 i s t r ue"
ELSEI F ( x = 7) THEN
PRI NT " St at ement 3 i s t r ue"
ELSE
PRI NT " No above st at ement s ar e t r ue"
END I F
Output:
No above st at ement s ar e t r ue
Multiple expressions
You can have more than one expression in I F. . . THEN by using either the OR operator or the
AND operator.
The OR operator only requires one expression to be true in order to print "Yes" in the following
program:
x = 20
I F ( x = 5 OR x = 20) THEN PRI NT " Yes"
Output:
Yes
The AND operator requires both expressions to be true.
x = 7
I F ( x > 5 AND x < 10) THEN PRI NT " Tr ue"
Output:
Tr ue
This is a slightly more complex example:
x = 16
y = 3
I F ( ( x > 5 AND x < 10) OR y = 3) THEN PRI NT " Cor r ect "
Output (since Y is 3):
Cor r ect
Strings in IF...THEN
So far in this chapter, we've only been dealing with numbers, but you can also use strings with
the I F. . . THEN command.
x$ = " Hel l o"
I F ( x$ = " Hel l o" OR x$ = " Wor l d" ) THEN PRI NT x$
Output:
Hel l o
You can also compare two variable strings:
x$ = " Hel l o"
y$ = " Wor l d"
I F ( x$ <> y$) THEN PRI NT x$; " " ; y$
Output:
Hel l o Wor l d
Labels and the GOTO and GOSUB commands
The GOTO and GOSUB commands enables you to jump to certain positions in your program.
Label s are used to specify what point in the program to continue execution.
GOTO
To use GOTO, place a label somewhere in your program, and then enter.
GOTO <l abel >
Run the following example program:
PRI NT " 1"
GOTO TheLabel
PRI NT " 2"
TheLabel :
PRI NT " 3"
Output (notice how PRI NT " 2" is skipped):
1
3
TIP: TheLabel can be placed on the same line
as PRI NT " 3"
TheLabel: PRINT " 3"
GOSUB
The GOSUB command is the same as GOTO, except when it encounters a RETURN statement, the
program "returns" back to the GOSUB command. In other words, RETURN continues program
execution immediately after the previous GOSUB statement.
PRI NT " 1"
GOSUB TheLabel
PRI NT " 2"
END
TheLabel :
PRI NT " 3"
RETURN
(Note: The END command exits the program.)
Since the program returns to the GOSUB command, the number 2 is printed this time.
1
3
2
Line numbers
"Line numbers" can be used as labels.
PRI NT " 1"
GOTO 10
PRI NT " 2"
10 PRI NT " 3" ( Not i ce t he l i ne number )
You can also write the program like this:
10 PRI NT " 1"
20 GOTO 40
30 PRI NT " 2"
40 PRI NT " 3"
The line numbers don't even have to be in sequence.
17 PRI NT " 1"
2 GOTO 160
701 PRI NT " 2"
160 PRI NT " 3"
Each of these programs output:
1
3
Loops
"Loops" make it easier to do an action multiple times. There are at least four types of loops:
I F. . . GOTO, WHI LE. . . WEND, DO. . . LOOP, and FOR. . . NEXT.
IF...GOTO
This program uses I F. . . GOTO to create a loop:
x = 10
st ar t :
PRI NT x
x = x + 1 ( Thi s adds 1 t o x)
I F x < 15 THEN GOTO st ar t
Output:
10
11
12
13
14
WHILE...WEND
The WHI LE. . . WEND commands continue a loop until a specified expression is false.
To use WHI LE. . . WEND:
1. Pl ace an expr essi on af t er WHI LE
2. Ent er a l i st of commands
3. Pl ace WEND at t he end
Run the following:
x = 10
WHI LE x < 15
PRI NT x
x = x + 1
WEND
Output (same as in previous example):
10
11
12
13
14
DO...LOOP
DO. . . LOOP is exactly the same as WHI LE. . . WEND, except it has at least two slight advantages.
With DO. . . LOOP you can:
1. Loop unt i l an expr essi on i s t r ue
2. Loop at l east one t i me r egar dl ess of whet her t he expr essi on i s
t r ue or not .
To use DO. . . LOOP:
1. Speci f y whet her t he l oop cont i nues " whi l e" t he expr essi on i s t r ue
or " unt i l " t he expr essi on i s t r ue, usi ng t he WHI LE and UNTI L
st at ement s, r espect i vel y.
2. Pl ace an expr essi on af t er WHI LE/ UNTI L
3. Ent er a l i st of commands
4. Pl ace LOOP at t he end
The following uses the WHI LE statement:
x = 10
DO WHI LE x < 15
PRI NT x
x = x + 1
LOOP
This program uses the UNTI L statement:
x = 10
DO UNTI L x = 15
PRI NT x
x = x + 1
LOOP
They both output:
10
11
12
13
14
If you place the expression at the end of the loop instead, the program goes through the loop at
least once.
x = 32
DO
PRI NT x
x = x + 1
LOOP WHI LE x < 5
This is the output because the loop was only gone through one time:
32
FOR...NEXT
FOR. . . NEXT provides an easier way to create a loop.
FOR x = 1 TO 5
PRI NT x
NEXT x
Output:
1
2
3
4
5
TIP: The X after NEXT is optional (unless you
have a loop within a loop).
Also, you can use the STEP attribute to specify how much X will be increased each time through
the loop.
FOR x = 1 TO 5 STEP 2
PRI NT x
NEXT x
Output:
1
3
5
STOPPING LOOPS
To stop a loop prematurely, use the EXI T command, followed by either FOR or DO.
FOR x = 1 TO 5
PRI NT x
I F ( x = 3) THEN EXI T FOR
NEXT x
Output:
1
2
3
(NOTE: This command only works with the DO. . . LOOP and FOR. . . NEXT commands, not with
WHI LE. . . WEND or I F. . . GOTO.)
Arrays
An array is a list of variables of the same type. Arrays are useful for organizing multiple variables.
To create an array, use the DI M(dimension) command.
The following example does not use arrays:
a = 2
b = 4
c = 6
d = 8
e = 10
PRI NT a, b, c, d, e
Output:
2 4 6 8 10
This uses an array called var s, which contains 5 variables:
DI M var s( 5)
' Each of t hese ar e separ at e var i abl es:
var s( 1) = 2
var s( 2) = 4
var s( 3) = 6
var s( 4) = 8
var s( 5) = 10
PRI NT var s( 1) , var s( 2) , var s( 3) , var s( 4) , var s( 5)
Output:
2 4 6 8 10
How an array of variables is stored in memory
(NOTE: Memory addresses are not necessarily as specified)
The above program can also be written like this:
DI M var s( 5)
FOR x = 1 t o 5
var s( x) = x * 2
NEXT
FOR x = 1 t o 5
PRI NT var s( x) ,
NEXT
Output:
2 4 6 8 10
Strings
You can also create an array of string variables.
DI M var s$( 5)
var s$( 1) = " Two"
var s$( 2) = " Four "
var s$( 3) = " Si x"
var s$( 4) = " Ei ght "
var s$( 5) = " Ten"
PRI NT var s$( 1) , var s$( 2) , var s$( 3) , var s$( 4) , var s$( 5)
Output:
Two Four Si x Ei ght Ten
Q-2Write a Q-basic Program to find the lattice density form the
following table
Metal Atomic weight Atomic radius
Ni 58.71 1.243
Al 26.98 1.432
Cu 51.996 1.299
Ag 67.868 1.445
Knowing that
p =
n A
w
I A
n


Also Knowing that for FCC
n=atoms number =4
Avogadro's number =6.02310
23

V=16* 2*r
3

Solutions
DIM m$(4), a(4), r(4), d(4)
FOR i =1 TO 4
N =4
AN =6.023E+23
READ a(i), r(i)
d(i) =(N * a(i)) / (AN * (16 * SQR(2) * r(i) ^3))
PRINT d(i)
NEXT i
DATA 58.71,1.243,26.98,1.432,51.996,1.29,67.868,1.445
FOR j =1 TO 4
READ m$(j)
PRINT "metal"; m$(j), "density"; d(j)
NEXT j
DATA Ni,Al,Cu,Ag
END
Q-3Write a Q-basic Program to find the lattice density form the
following table
Metal Atomic weight Atomic radius
Cr 51.966 1.249
Nb 92.91 1.426
W 183.85 1.377
Li 6.94 1.887
Knowing that
p =
n A
w
I A
n


v =
64 r
3
SS
Also Knowing that for FCC
n=atoms number =2
Avogadro's number =6.02310
23

2

Solutions
DIM m$(4), a(4), r(4), d(4)
FOR I =1 TO 4
N =2
AN =6.023E+23
READ a(I), r(I)
v =(64 * r(I) ^3) / (3 * 3 ^(1 / 3))
d(I) =(N * a(I)) / (AN * v)
NEXT I
DATA 51.996,1.249,92.91,1.426,183.85,1.37,6.94,1.887
FOR j =1 TO 4
READ m$(j)
PRINT "metal"; m$(j), "density"; d(j)
NEXT j
DATA Cr,Nb,W,Li
END
Q4- write a quick-basic program to find molecular weight for polymer
Mi fi
0-3000 0.01
3000-6000 0.08
6000-9000 0.19
9000-12000 0.27
12000-15000 0.23
15000-18000 0.11
18000-21000 0.06
21000-24000 0.05
Knowing that
w
m
=


Solutions
DIM w(8), f(8)
FOR i = 1 TO 8
w(i) = ((i * 3000) + ((i * 3000) - 3000)) / 2
NEXT i
FOR j = 1 TO 8
READ f(j)
mw = mw + (w(j) * f(j))
NEXT j
PRINT " atomic weight"; mw
DATA 0.01,0.08,0.19,0.27,0.23,0.11,0.06,0.05
END



Q5- write a quick-basic program to find molecular Number for polymer
M
i
x
i

0-3000 0.03
3000-6000 0.1
6000-9000 0.22
9000-12000 0.36
12000-15000 0.19
15000-18000 0.07
18000-21000 0.02
21000-24000 0.01
Knowing that
w
n
= x


Solutions
DIM w(8), x(8)
FOR i =1 TO 8
w(i) =((i * 3000) +((i * 3000) - 3000)) / 2
NEXT i
FOR j =1 TO 8
READ x(j)
mw =mw +(w(j) * x(j))
NEXT j
PRINT " atomic weight"; mw
DATA 0.03,0.1,0.22,0.36,0.19,0.07,0.02,0.01
END




Q-1For the following material has properties
Density =6.4
Atomic radius=1.223
Atomic weight =43.1
Write a quick basic program to give a specific identification for crystal
structure (FCC,BCC,SC)
DIM a(3), apf(3)
d =6.4
aw =43.1
v =d / aw
r =1.22
a(1) =16 * SQR(2) * r ^3
apf(1) =v / a(1)
a(2) =(64 * r ^3) / (3 * 3 ^(1 / 3))
apf(2) =v / a(2)
a(3) =8 * r ^3
apf(3) =v / a(3)
PRINT apf(1)
PRINT apf(2)
PRINT apf(3)
END




Q6 write a quick basic program to classifies materials as very light ,
light , medium , heavy
Metal Density
Al 2.699
Cr 7.19
Ti 4.5
Li 0.534
Ni 8.9
Cu 8.93
Fe 7.87

Solution
Dimension a$(8),d(8)
FOR i =1 TO 8
Read a$, D
IF D <2.5 THEN
PRINT a$; "is a Very Light Metal "
ELSEIF D >2.5 AND D <3.5 THEN
PRINT a$; "is Light Material"
ELSEIF D >3.5 AND D <5.2 THEN
PRINT a$; "is Medium Metals"
ELSE
PRINT a$; "is Heavy Metal"
END IF
NEXT i
Data al,2.699,cr ,7.19, ti,4.5, li,0.534,ni,8.9,cu,8.93fe,7.87
END

Mathematics functions
QBasic provides several functions to do mathematical calculations. A few of them are discussed
here.
SQR
Use SQR to find the " square root" of a number.
PRI NT SQR( 1)
PRI NT SQR( 4)
PRI NT SQR( 9)
PRI NT SQR( 16)
PRI NT SQR( 25)
Output:
1
2
3
4
5
ABS
ABS returns the absolute value of a number. In other words, ABS converts a negative number to
a positive number (if you pass a positive number, ABS does nothing).
PRI NT ABS( 12)
PRI NT ABS( - 12)
Output:
12
12
COS, SIN, TAN, and ATN
You can do the following trigonometric functions in QBasic:
COS ( Cosi ne)
SI N ( Si ne)
TAN ( Tangent )
ATN ( Ar ct angent , i nver se of TAN)
Example:
CONST PI = 3. 141593
PRI NT COS( PI / 4)
PRI NT SI N( PI / 3)
PRI NT TAN( - PI / 2)
PRI NT ATN( TAN( - PI / 2) )
Output:
. 7071067
. 8660254
6137956
1. 570796 ( Same as PI / 2)
The IF and THEN commands
The I F and THEN commands are used to compare an expression and then perform some task
based on that expression.
x = 5
I F x = 5 THEN PRI NT " x equal s 5"
Since X does equal 5 in this case, the program outputs:
x equal s 5
Expression signs
You can also enter the following statements, instead of the equals sign:
x < 5 ( x i s l ess t han 5)
x > 5 ( x i s gr eat er t han 5)
Run the following:
x = 16
I F ( x > 5) THEN PRI NT " x i s gr eat er t han 5"
Output:
x i s gr eat er t han 5
You can also combine the signs like this:
x <= 5 ( x i s l ess t han or equal t o 5)
x >= 5 ( x i s gr eat er t han or equal t o 5)
x <> 5 ( x does not equal 5)
Run the following example:
CLS
x = 5
I F ( x >= 5) THEN PRI NT " x i s gr eat er t han or equal t o 5"
I F ( x <= 5) THEN PRI NT " x i s l ess t han or equal t o 5"
I F ( x <> 5) THEN PRI NT " x does not equal 5"
Output:
x i s gr eat er t han or equal t o 5
x i s l ess t han or equal t o 5
ELSE
Using the ELSE command, you can have the program perform a different action if the statement
is false.
x = 3
I F x = 5 THEN PRI NT " Yes" ELSE PRI NT " No"
Since X doesn't equal 5, the output is:
No
END IF
END I F allows you to have multiple commands after the I F. . . THEN statement, but they must
start on the line after the I F statement. END I F should appear right after the list of commands.
x = 5
I F ( x = 5) THEN
I NPUT a$
PRI NT a$
END I F
The following program uses ELSE with the END I F command:
x = 16
I F ( x = 5) THEN
I NPUT a$
PRI NT a$
ELSE
PRI NT x * 2
END I F
Output:
32
TIP: There is a way to have multipl e commands
after I F. . . THEN without using END I F. To do
so, place a colon between each command.
IF (x = 5) THEN INPUT a$: PRINT a$
ELSEIF
The ELSEI F command allows you to perform a secondary action if the first expression was false.
Unlike ELSE, this task is only performed if a specified statement is true.
x = 6
I F ( x = 5) THEN
PRI NT " St at ement 1 i s t r ue"
ELSEI F ( x = 6) THEN
PRI NT " St at ement 2 i s t r ue"
END I F
Output:
St at ement 2 i s t r ue
You can have multiple ELSEI F commands, along with ELSE.
x = 8
I F ( x = 5) THEN
PRI NT " St at ement 1 i s t r ue"
ELSEI F ( x = 6) THEN
PRI NT " St at ement 2 i s t r ue"
ELSEI F ( x = 7) THEN
PRI NT " St at ement 3 i s t r ue"
ELSE
PRI NT " No above st at ement s ar e t r ue"
END I F
Output:
No above st at ement s ar e t r ue
Multiple expressions
You can have more than one expression in I F. . . THEN by using either the OR operator or the
AND operator.
The OR operator only requires one expression to be true in order to print "Yes" in the following
program:
x = 20
I F ( x = 5 OR x = 20) THEN PRI NT " Yes"
Output:
Yes
The AND operator requires both expressions to be true.
x = 7
I F ( x > 5 AND x < 10) THEN PRI NT " Tr ue"
Output:
Tr ue
This is a slightly more complex example:
x = 16
y = 3
I F ( ( x > 5 AND x < 10) OR y = 3) THEN PRI NT " Cor r ect "
Output (since Y is 3):
Cor r ect
Strings in IF...THEN
So far in this chapter, we've only been dealing with numbers, but you can also use strings with
the I F. . . THEN command.
x$ = " Hel l o"
I F ( x$ = " Hel l o" OR x$ = " Wor l d" ) THEN PRI NT x$
Output:
Hel l o
You can also compare two variable strings:
x$ = " Hel l o"
y$ = " Wor l d"
I F ( x$ <> y$) THEN PRI NT x$; " " ; y$
Output:
Hel l o Wor l d
Labels and the GOTO and GOSUB commands
The GOTO and GOSUB commands enables you to jump to certain positions in your program.
Label s are used to specify what point in the program to continue execution.
GOTO
To use GOTO, place a label somewhere in your program, and then enter.
GOTO <l abel >
Run the following example program:
PRI NT " 1"
GOTO TheLabel
PRI NT " 2"
TheLabel :
PRI NT " 3"
Output (notice how PRI NT " 2" is skipped):
1
3
TIP: TheLabel can be placed on the same line
as PRI NT " 3"
TheLabel: PRINT " 3"
GOSUB
The GOSUB command is the same as GOTO, except when it encounters a RETURN statement, the
program "returns" back to the GOSUB command. In other words, RETURN continues program
execution immediately after the previous GOSUB statement.
PRI NT " 1"
GOSUB TheLabel
PRI NT " 2"
END
TheLabel :
PRI NT " 3"
RETURN
(Note: The END command exits the program.)
Since the program returns to the GOSUB command, the number 2 is printed this time.
1
3
2
Line numbers
"Line numbers" can be used as labels.
PRI NT " 1"
GOTO 10
PRI NT " 2"
10 PRI NT " 3" ( Not i ce t he l i ne number )
You can also write the program like this:
10 PRI NT " 1"
20 GOTO 40
30 PRI NT " 2"
40 PRI NT " 3"
The line numbers don't even have to be in sequence.
17 PRI NT " 1"
2 GOTO 160
701 PRI NT " 2"
160 PRI NT " 3"
Each of these programs output:
1
3
Loops
"Loops" make it easier to do an action multiple times. There are at least four types of loops:
I F. . . GOTO, WHI LE. . . WEND, DO. . . LOOP, and FOR. . . NEXT.
IF...GOTO
This program uses I F. . . GOTO to create a loop:
x = 10
st ar t :
PRI NT x
x = x + 1 ( Thi s adds 1 t o x)
I F x < 15 THEN GOTO st ar t
Output:
10
11
12
13
14
WHILE...WEND
The WHI LE. . . WEND commands continue a loop until a specified expression is false.
To use WHI LE. . . WEND:
1. Pl ace an expr essi on af t er WHI LE
2. Ent er a l i st of commands
3. Pl ace WEND at t he end
Run the following:
x = 10
WHI LE x < 15
PRI NT x
x = x + 1
WEND
Output (same as in previous example):
10
11
12
13
14
DO...LOOP
DO. . . LOOP is exactly the same as WHI LE. . . WEND, except it has at least two slight advantages.
With DO. . . LOOP you can:
1. Loop unt i l an expr essi on i s t r ue
2. Loop at l east one t i me r egar dl ess of whet her t he expr essi on i s
t r ue or not .
To use DO. . . LOOP:
1. Speci f y whet her t he l oop cont i nues " whi l e" t he expr essi on i s t r ue
or " unt i l " t he expr essi on i s t r ue, usi ng t he WHI LE and UNTI L
st at ement s, r espect i vel y.
2. Pl ace an expr essi on af t er WHI LE/ UNTI L
3. Ent er a l i st of commands
4. Pl ace LOOP at t he end
The following uses the WHI LE statement:
x = 10
DO WHI LE x < 15
PRI NT x
x = x + 1
LOOP
This program uses the UNTI L statement:
x = 10
DO UNTI L x = 15
PRI NT x
x = x + 1
LOOP
They both output:
10
11
12
13
14
If you place the expression at the end of the loop instead, the program goes through the loop at
least once.
x = 32
DO
PRI NT x
x = x + 1
LOOP WHI LE x < 5
This is the output because the loop was only gone through one time:
32
FOR...NEXT
FOR. . . NEXT provides an easier way to create a loop.
FOR x = 1 TO 5
PRI NT x
NEXT x
Output:
1
2
3
4
5
TIP: The X after NEXT is optional (unless you
have a loop within a loop).
Also, you can use the STEP attribute to specify how much X will be increased each time through
the loop.
FOR x = 1 TO 5 STEP 2
PRI NT x
NEXT x
Output:
1
3
5
STOPPING LOOPS
To stop a loop prematurely, use the EXI T command, followed by either FOR or DO.
FOR x = 1 TO 5
PRI NT x
I F ( x = 3) THEN EXI T FOR
NEXT x
Output:
1
2
3
(NOTE: This command only works with the DO. . . LOOP and FOR. . . NEXT commands, not with
WHI LE. . . WEND or I F. . . GOTO.)
Arrays
An array is a list of variables of the same type. Arrays are useful for organizing multiple variables.
To create an array, use the DI M(dimension) command.
The following example does not use arrays:
a = 2
b = 4
c = 6
d = 8
e = 10
PRI NT a, b, c, d, e
Output:
2 4 6 8 10
This uses an array called var s, which contains 5 variables:
DI M var s( 5)
' Each of t hese ar e separ at e var i abl es:
var s( 1) = 2
var s( 2) = 4
var s( 3) = 6
var s( 4) = 8
var s( 5) = 10
PRI NT var s( 1) , var s( 2) , var s( 3) , var s( 4) , var s( 5)
Output:
2 4 6 8 10
How an array of variables is stored in memory
(NOTE: Memory addresses are not necessarily as specified)
The above program can also be written like this:
DI M var s( 5)
FOR x = 1 t o 5
var s( x) = x * 2
NEXT
FOR x = 1 t o 5
PRI NT var s( x) ,
NEXT
Output:
2 4 6 8 10
Strings
You can also create an array of string variables.
DI M var s$( 5)
var s$( 1) = " Two"
var s$( 2) = " Four "
var s$( 3) = " Si x"
var s$( 4) = " Ei ght "
var s$( 5) = " Ten"
PRI NT var s$( 1) , var s$( 2) , var s$( 3) , var s$( 4) , var s$( 5)
Output:
Two Four Si x Ei ght Ten
Q-2Write a Q-basic Program to find the lattice density form the
following table
Metal Atomic weight Atomic radius
Ni 58.71 1.243
Al 26.98 1.432
Cu 51.996 1.299
Ag 67.868 1.445
Knowing that
p =
n A
w
I A
n


Also Knowing that for FCC
n=atoms number =4
Avogadro's number =6.02310
23

V=16* 2*r
3

Solutions
DIM m$(4), a(4), r(4), d(4)
FOR i =1 TO 4
N =4
AN =6.023E+23
READ a(i), r(i)
d(i) =(N * a(i)) / (AN * (16 * SQR(2) * r(i) ^3))
PRINT d(i)
NEXT i
DATA 58.71,1.243,26.98,1.432,51.996,1.29,67.868,1.445
FOR j =1 TO 4
READ m$(j)
PRINT "metal"; m$(j), "density"; d(j)
NEXT j
DATA Ni,Al,Cu,Ag
END
Q-3Write a Q-basic Program to find the lattice density form the
following table
Metal Atomic weight Atomic radius
Cr 51.966 1.249
Nb 92.91 1.426
W 183.85 1.377
Li 6.94 1.887
Knowing that
p =
n A
w
I A
n


v =
64 r
3
SS
Also Knowing that for FCC
n=atoms number =2
Avogadro's number =6.02310
23

2

Solutions
DIM m$(4), a(4), r(4), d(4)
FOR I =1 TO 4
N =2
AN =6.023E+23
READ a(I), r(I)
v =(64 * r(I) ^3) / (3 * 3 ^(1 / 3))
d(I) =(N * a(I)) / (AN * v)
NEXT I
DATA 51.996,1.249,92.91,1.426,183.85,1.37,6.94,1.887
FOR j =1 TO 4
READ m$(j)
PRINT "metal"; m$(j), "density"; d(j)
NEXT j
DATA Cr,Nb,W,Li
END
Q4- write a quick-basic program to find molecular weight for polymer
Mi fi
0-3000 0.01
3000-6000 0.08
6000-9000 0.19
9000-12000 0.27
12000-15000 0.23
15000-18000 0.11
18000-21000 0.06
21000-24000 0.05
Knowing that
w
m
=


Solutions
DIM w(8), f(8)
FOR i = 1 TO 8
w(i) = ((i * 3000) + ((i * 3000) - 3000)) / 2
NEXT i
FOR j = 1 TO 8
READ f(j)
mw = mw + (w(j) * f(j))
NEXT j
PRINT " atomic weight"; mw
DATA 0.01,0.08,0.19,0.27,0.23,0.11,0.06,0.05
END



Q5- write a quick-basic program to find molecular Number for polymer
M
i
x
i

0-3000 0.03
3000-6000 0.1
6000-9000 0.22
9000-12000 0.36
12000-15000 0.19
15000-18000 0.07
18000-21000 0.02
21000-24000 0.01
Knowing that
w
n
= x


Solutions
DIM w(8), x(8)
FOR i =1 TO 8
w(i) =((i * 3000) +((i * 3000) - 3000)) / 2
NEXT i
FOR j =1 TO 8
READ x(j)
mw =mw +(w(j) * x(j))
NEXT j
PRINT " atomic weight"; mw
DATA 0.03,0.1,0.22,0.36,0.19,0.07,0.02,0.01
END




Q-1For the following material has properties
Density =6.4
Atomic radius=1.223
Atomic weight =43.1
Write a quick basic program to give a specific identification for crystal
structure (FCC,BCC,SC)
DIM a(3), apf(3)
d =6.4
aw =43.1
v =d / aw
r =1.22
a(1) =16 * SQR(2) * r ^3
apf(1) =v / a(1)
a(2) =(64 * r ^3) / (3 * 3 ^(1 / 3))
apf(2) =v / a(2)
a(3) =8 * r ^3
apf(3) =v / a(3)
PRINT apf(1)
PRINT apf(2)
PRINT apf(3)
END




Q6 write a quick basic program to classifies materials as very light ,
light , medium , heavy
Metal Density
Al 2.699
Cr 7.19
Ti 4.5
Li 0.534
Ni 8.9
Cu 8.93
Fe 7.87

Solution
Dimension a$(8),d(8)
FOR i =1 TO 8
Read a$, D
IF D <2.5 THEN
PRINT a$; "is a Very Light Metal "
ELSEIF D >2.5 AND D <3.5 THEN
PRINT a$; "is Light Material"
ELSEIF D >3.5 AND D <5.2 THEN
PRINT a$; "is Medium Metals"
ELSE
PRINT a$; "is Heavy Metal"
END IF
NEXT i
Data al,2.699,cr ,7.19, ti,4.5, li,0.534,ni,8.9,cu,8.93fe,7.87
END

Tutorials
Q. Write an algorithm and graph a flowchart for the following .
1. The area & the volume of a Cylinder
2. The area & the volume of a Hollow Cylinder
3. The area & the volume of a Sphere
4. The area & the volume of a Hemi-Sphere
5. The area & the volume of a Cone
6. The area & the volume of a Cube
7. The relationship y =
3sInx
+cos x snx

8. The relationship y =
x
x+2cosx sIn

9. The function of x y = _
x
2
x
2
+1
2
i y u or y = _
x
2
x
2
-1
2
i

x
2
x
2
-1
> u
10. The function of x y = i y u or y =
x
2
x
2
+1
i
= sinx i y
n
4
> u
11. The function of x y or y = cos x
n
i >
4

12. The triangle functions for the following angles
(0,30,37,45,53,60,90)
13. The solving of an equation by constitution
14. The summations and the average of productions of factory of
utomotive spare parts a










Tutorials:2 Programming
Q. Write a Quick Basic Program to solve the following
1. The area & the volume of a Cylinder
2. The area & the volume of a Hollow Cylinder
3. The area & the volume of a Sphere
4. The area & the volume of a Hemi-Sphere
5. The area & the volume of a Cone
6. The area & the volume of a Cube
7. The relationship y =
Inx
+cos x
3s
snx

8. The relationship y =
x
+2cosx sInx

9. The function of x y = _
x
2
x
2
+1
2
i y u or y = _
x
2
x
2
-1
2
i

x
2
x
2
-1
> u
10. The function of x y = i y u or y =
x
2
x
2
+1
i
y = sinx i y
4
> u
11. The function of x
n
or y = cos x i >
n

4

12. The triangle functions for the following angles
(0,30,37,45,53,60,90)
13. The solving of an equation by constitution
14. The summations and the average of productions of
factory of automotive spare parts
Y=X -1
Y=X -4
Y=X -9

15. The value of Y for X on both extremes
2
2
2
16.to Classifies materials according to atomic weight
17. to find the atomic packing factor for metals.
18. to find the integer square from 1 to 120
19. to find the Real square from 1 to 120
20. to find the integer Cubic from 1 to 120
21. to find the real Cubic from 1 to 120
22. find the resultant force for the following object
15
23. find the resultant force and the moment for the following
object (all are in Newton)
30

20
25

24. the solution s for the following Y=e
X+1

25. the Number of Defected Valves for 100 valve Knowing that
the safety limit is 5 Bar

Sheet #3 1
st
Class Materials Engineering Department
Raau Suhail Bafiuh Page 1

Tutorials Sheet 3

Q-1For the following material has properties
Density =6.4
Atomic radius=1.223
Atomic weight =43.1
Write a quick basic program to give a specific identification for
crystal structure (FCC,BCC,SC)

Q-2Write a Q-basic Program to find the lattice density form the
following table
Metal Atomic weight Atomic radius
Ni 58.71 1.243
Al 26.98 1.432
Cu 51.996 1.299
Ag 67.868 1.445
Knowing that
p =
n A
w
I A
n


Also Knowing that for FCC
n=atoms number =4
Avogadro's number =6.02310
23

V=16* 2*r
3







Sheet #3 1
st
Class Materials Engineering Department
Raau Suhail Bafiuh Page 2


Q-3Write a Q-basic Program to find the lattice density form the
following table
Metal Atomic weight Atomic radius
Cr 51.966 1.249
Nb 92.91 1.426
W 183.85 1.377
Li 6.94 1.887
Knowing that
p =
n A
w
I A
n


v =
64 r
3
SS
Also Knowing that for FCC
n=atoms number =2
Avogadro's number =6.02310
23

2



Q4- write a quick-basic program to find molecular weight for polymer
Mi fi
0-3000 0.01
3000-6000 0.08
6000-9000 0.19
9000-12000 0.27
12000-15000 0.23
15000-18000 0.11
18000-21000 0.06
21000-24000 0.05
Knowing that
w
m
=







Sheet #3 1
st
Class Materials Engineering Department
Raau Suhail Bafiuh Page S

5- write a quick-basic program to find molecular Number for


M
i
x
i

Q
polymer
0-3000 0.03
3000-6000 0.1
6000-9000 0.22
9000-12000 0.36
12000-15000 0.19
15000-18000 0.07
18000-21000 0.02
21000-24000 0.01
Knowing that
w
n
= x