Intro to Computer Science Basics
Intro to Computer Science Basics
OBJECTIVES
The specific objectives of this course are to:
1. Understand the history, classification and impact of computers.
2. Know the concept of computer hardware and software.
3. Understand features of a good program.
4. Understand the concept of Algorithms and flowcharting.
5. Understand the principles of designing algorithms for common programming problem.
6. Understand the concept of debugging and maintaining program.
LEARNING OUTCOMES
The students should be able to:
1. Define computer
2. Know the history, classification and computer applications
3. Know the concept of computer hardware
4. Know the concept of computer software.
5. Know the data preparation methods
6. Know the Characteristics of a Computer.
7. Know features of a good program.
8. Explain the concept of Computer problem solving techniques, Algorithms and
flowcharting.
9. Explain General modular program design principles.
10. Explain expressions and control structure.
11. Explain the procedure in solving programming problems.
12. Explain the concept of debugging and maintaining program.
13. Know programming style in BASIC
14. Know how to debug programs in BASIC.
TEXT BOOK(S):
1. Goel, A. (2010). Computer fundamentals. Pearson Education India.
2. Chivers, I. D., & Sleightholme, J. (2018). Introduction to programming with Fortran
(Vol. 2). Cham: Springer.
Course Writer/Developer: Dr. F.E. AYO, Department of Mathematical Sciences, Computer
science unit, Olabisi Onabanjo University, Ago-Iwoye.
E-mail: ayo.femi@oouagoiwoye.edu.ng
LESSON 1
DEFINITION OF COMPUTER
A computer is an electronic device that accepts data from the user, processes it, produces
results, displays them to the users, and stores the results for future usage.
In other words, a computer is basically defined as a tool or machine used for processing data
to give required information. It is capable of:
1. taking input data through the keyboard (input unit)
2. storing the input data in a diskette, hard disk or other medium
3. processing it at the central processing unit (CPU) and
4. giving out the result (output) on the screen or the Visual Display Unit (VDU).
CHARACTERISTICS OF A COMPUTER
The characteristics of the computer system are as follows –
HISTORY OF COMPUTER
The history of computer can be classified into generations.
Initially, the generation term was used to distinguish between varying hardware technologies.
Nowadays, generation includes both hardware and software, which together make up an entire
computer system.
There are five computer generations known till date. Each generation has been discussed in
detail along with their time period and characteristics. Following are the main five generations
of computers.
First Generation Computers
The period of first generation was from 1946-1959. The computers of first generation used
vacuum tubes as the basic components for memory and circuitry for CPU (Central Processing
Unit). These tubes, like electric bulbs, produced a lot of heat and the installations used to fuse
frequently. Therefore, they were very expensive and only large organizations were able to
afford it.
In this generation, mainly batch processing operating system was used. Punch cards, paper
tape, and magnetic tape was used as input and output devices. The computers in this generation
used machine code as the programming language.
The main features of the first generation are:
Vacuum tube technology
Unreliable
Supported machine language only
Very costly
Generated a lot of heat
Slow input and output devices
Huge size
Need of AC
Non-portable
Consumed a lot of electricity
Example is mainframe computer
Second Generation Computers
The period of second generation was from 1959-1965. In this generation, transistors were used
that were cheaper, consumed less power, more compact in size, more reliable and faster than
the first generation machines made of vacuum tubes. In this generation, magnetic cores were
used as the primary memory and magnetic tape and magnetic disks as secondary storage
devices.
In this generation, assembly language and high-level programming languages like FORTRAN,
COBOL were used. The computers used batch processing and multiprogramming operating
system.
The main features of second generation are:
Use of transistors
Reliable in comparison to first generation computers
Smaller size as compared to first generation computers
Generated less heat as compared to first generation computers
Consumed less electricity as compared to first generation computers
Faster than first generation computers
Still very costly
AC required
Supported machine and assembly languages
Examples are IBM 1620 and IBM 7094
Third Generation Computers
The period of third generation was from 1965-1971. The computers of third generation used
Integrated Circuits (ICs) in place of transistors. A single IC has many transistors, resistors, and
capacitors along with the associated circuitry.
The IC was invented by Jack Kilby. This development made computers smaller in size, reliable,
and efficient. In this generation remote processing, time-sharing, multiprogramming operating
system were used. High-level languages (FORTRAN-II TO IV, COBOL, PASCAL PL/1,
BASIC, ALGOL-68 etc.) were used during this generation.
The main features of third generation are:
IC used
More reliable in comparison to previous two generations
Smaller size
Generated less heat
Faster
Lesser maintenance
Costly
AC required
Consumed lesser electricity
Supported high-level language
Examples are IBM-360 series, Honeywell-6000 series and PDP (Personal Data
Processor).
Fourth Generation Computers
The period of fourth generation was from 1971-1980. Computers of fourth generation used
Very Large Scale Integrated (VLSI) circuits. VLSI circuits having about 5000 transistors and
other circuit elements with their associated circuits on a single chip made it possible to have
microcomputers of fourth generation.
Fourth generation computers became more powerful, compact, reliable, and affordable. As a
result, it gave rise to Personal Computer (PC) revolution. In this generation, time sharing, real
time networks, distributed operating system were used. All the high-level languages like C,
C++, Java, etc., were used in this generation.
The main features of fourth generation are:
VLSI technology used
Very cheap
Portable and reliable
Use of PCs
Very small size
Pipeline processing
No AC required
Concept of internet was introduced
Great developments in the fields of networks
Computers became easily available
Example include Super Computers
Fifth Generation Computers
The period of fifth generation is 1980-till date. In the fifth generation, VLSI technology became
ULSI (Ultra Large Scale Integration) technology, resulting in the production of microprocessor
chips having ten million electronic components.
This generation is based on parallel processing hardware and AI (Artificial Intelligence)
software. AI is an emerging branch in computer science, which interprets the means and
method of making computers think like human beings. All the high-level languages like C and
C++, Java, python, .Net etc., are used in this generation.
AI includes:
Robotics
Neural Networks
Game Playing
Development of expert systems to make decisions in real-life situations
Natural language understanding and generation
The main features of fifth generation are:
ULSI technology
Development of true artificial intelligence
Development of Natural language processing
Advancement in Parallel Processing
Advancement in Superconductor technology
More user-friendly interfaces with multimedia features
Availability of very powerful and compact computers at cheaper rates
Some computer types of this generation are: Desktop, Laptop, NoteBook, UltraBook
and ChromeBook.
KEYBOARD
Keyboard is the most common and very popular input device which helps to input data to the
computer. The layout of the keyboard is like that of traditional typewriter, although there are
some additional keys provided for performing additional functions.
Keyboards are of two sizes 84 keys or 101/102 keys, but now keyboards with 104 keys or 108
keys are also available for Windows and Internet.
The keys on the keyboard are as follows:
S/N Keys Description
These keys include the letter keys (A-Z) and digit keys (0-
1 Typing Keys 9) which generally give the same layout as that of
typewriters.
It is used to enter the numeric data or cursor movement.
Generally, it consists of a set of 17 keys that are laid out
2 Numeric Keypad
in the same configuration used by most adding machines
and calculators.
The twelve function keys are present on the keyboard
which are arranged in a row at the top of the keyboard.
3 Function Keys
Each function key has a unique meaning and is used for
some specific purpose.
These keys provide cursor and screen control. It includes
four directional arrow keys. Control keys also include
4 Control keys
Home, End, Insert, Delete, Page Up, Page Down,
Control(Ctrl), Alternate(Alt), Escape(Esc).
Keyboard also contains some special purpose keys such as
Special Purpose
5 Enter, Shift, Caps Lock, Num Lock, Space bar, Tab, and
Keys
Print Screen.
Output Devices
Output device Characteristic
Monitor A monitor is most common type of output device.
It is also called as “Visual Display Unit”.
The inputs given by keyboard or any other input devices will
get displayed on monitor.
Cathode Ray Tube (CRT) and Flat panel display monitors are
commonly used monitors.
Printers Printers are most common type of output devices which are
used to take a hard copy of any digital document.
The two types of printers are impact and non-impact printers.
Non-impact printers such as laser and inkjet printers are less
noisy, more reliable and faster and also offer high quality
compared to impact printers.
Sound Systems Sound systems are output devices which are used to get
multimedia content such as voice, music, etc., as output. Some
of examples of sound systems are speakers, headphones, and
microphones.
PRINTERS
Printer is an output device, which is used to print information on paper.
There are two types of printers:
Impact Printers
Non-Impact Printers
Impact Printers
Impact printers print the characters by striking them on the ribbon, which is then pressed on
the paper.
Characteristics of Impact Printers are the following:
Very low consumable costs
Very noisy
Useful for bulk printing due to low cost
There is physical contact with the paper to produce an image
These printers are of two types -
1. Character printers
2. Line printers
Character Printers
Character printers are the printers which print one character at a time.
These are further divided into two types:
Dot Matrix Printer (DMP)
Daisy Wheel
Dot Matrix Printer
In the market, one of the most popular printers is Dot Matrix Printer. These printers are popular
because of their ease of printing and economical price. Each character printed is in the form of
pattern of dots and head consists of a Matrix of Pins of size (5*7, 7*9, 9*7 or 9*9) which come
out to form a character which is why it is called Dot Matrix Printer.
Advantages
Inexpensive
Widely Used
Other language characters can be printed
Disadvantages
Slow Speed
Poor Quality
Daisy Wheel
Head is lying on a wheel and pins corresponding to characters are like petals of Daisy (flower)
which is why it is called Daisy Wheel Printer. These printers are generally used for word-
processing in offices that require a few letters to be sent here and there with very nice quality.
Advantages
More reliable than DMP
Better quality
Fonts of character can be easily changed
Disadvantages
Slower than DMP
Noisy
More expensive than DMP
Line Printers
Line printers are the printers which print one line at a time.
These are of two types -
Drum Printer
Chain Printer
Drum Printer
This printer is like a drum in shape hence it is called drum printer. The surface of the drum is
divided into a number of tracks. Total tracks are equal to the size of the paper, i.e. for a paper
width of 132 characters, drum will have 132 tracks. A character set is embossed on the track.
Different character sets available in the market are 48 character set, 64 and 96 characters set.
One rotation of drum prints one line. Drum printers are fast in speed and can print 300 to 2000
lines per minute.
Advantages
Very high speed
Disadvantages
Very expensive
Characters fonts cannot be changed
Chain Printer
In this printer, a chain of character sets is used, hence it is called Chain Printer. A standard
character set may have 48, 64, or 96 characters.
Advantages
Character fonts can easily be changed.
Different languages can be used with the same printer.
Disadvantages
Noisy
Non-impact Printers
Non-impact printers print the characters without using the ribbon. These printers print a
complete page at a time, thus they are also called as Page Printers.
These printers are of two types -
Laser Printers
Inkjet Printers
Characteristics of Non-impact Printers
Faster than impact printers
They are not noisy
High quality
Supports many fonts and different character size
Laser Printers
These are non-impact page printers. They use laser lights to produce the dots needed to form
the characters to be printed on a page.
Advantages
Very high speed
Very high quality output
Good graphics quality
Supports many fonts and different character size
Disadvantages
Expensive
Cannot be used to produce multiple copies of a document in a single printing
Inkjet Printers
Inkjet printers are non-impact character printers based on a relatively new technology. They
print characters by spraying small drops of ink onto paper. Inkjet printers produce high quality
output with presentable features.
They make less noise because no hammering is done and these have many styles of printing
modes available. Colour printing is also possible. Some models of Inkjet printers can produce
multiple copies of printing also.
Advantages
High quality printing
More reliable
Disadvantages
Expensive as the cost per page is high
Slow as compared to laser printer
COMPUTER MEMORY
Computer memory refers to storage area where data is stored. It is of two types:
Primary Memory
Secondary Memory
Primary Memory
Primary memory is the main memory of computer present in motherboard. Primary memory is
of two types as shown in the image below.
Random Access Memory
RAM is referred as temporary memory, in which, information stored is lost once computer is
turned off. It is a volatile memory. Instructions written in this memory can be modified; hence
it is also known as programmable memory. The two types of RAM are Static RAM (faster and
costlier) and Dynamic RAM.
Functions of RAM
It stores data till it gets processed.
It stores instructions for data processing.
It acts as a working space where data processing takes place and intermediate results
are stored.
It stores processed data/results before it is sent to output devices.
Read Only Memory
ROM is referred as permanent memory, in which information stored is available even if
computer is turned off. Instructions stored in this memory can only be read and cannot be
modified. Mostly ROM has a start-up instruction which is executed every time when computer
is switched on. Types of ROM are PROM (Programmable Read Only Memory), EPROM
(Erasable PROM), EEPROM (Electrically Erasable PROM) and flash memory.
HARDWARE
The term hardware refers to mechanical device that makes up computer. Computer hardware
consists of interconnected electronic devices that we can use to control computer’s operation,
input and output. Examples of hardware are CPU, keyboard, mouse, hard disk, etc.
Hardware Components
Computer hardware is a collection of several components working together. Some parts are
essential and others are added advantages. Computer hardware is made up of CPU and
peripherals as shown in image below.
System Software
System software operates directly on hardware devices of computer. It provides a platform to
run an application. It provides and supports user functionality. Examples of system software
include operating systems such as Windows, Linux, Unix, etc.
Application Software
An application software is designed for benefit of users to perform one or more tasks. Examples
of application software include Microsoft Word, Excel, PowerPoint, Oracle, etc.
CLASSIFICATION OF COMPUTERS
The computer has passed through many stages of evolution from the days of the mainframe
computers to the era of microcomputers. Computers have been classified based on different
criteria. In this unit, we shall classify computers based on three popular methods.
Objectives
The objectives of this unit are to:
i. Classify computers based on size, type of signal and purpose.
ii. Study the features that differentiate one class of the computer from the others.
Categories of Computers
Although there are no industry standards, computers are generally classified in the following
ways:
Classification based on signal type
Digital computer
Analogue computer
Hybrid computer
Classification by purpose
Special purpose
General purpose
Classification by capacity
Mainframe
Mini computers
Micro computers
CLASSIFICATION BY PURPOSE
Depending on their flexibility in operation, computers are classified as either special purpose
or general purpose.
Special Purpose Computers
A special purpose computer is one that is designed to solve a restricted class of problems. Such
computers may even be designed and built to handle only one job. In such machines, the steps
or operations that the computer follows may be built into the hardware. Most of the computers
used for military purposes fall into this class. Other example of special purpose computers
include:
Computers designed specifically to solve navigational problems.
Computers designed for tracking airplane or missiles.
Computers used for process control applications in industries such as oil refinery,
chemical manufacture, steel processing and power generation.
Computers used as robots in factories like vehicles assembly plants and glass industries.
Attributes of Special Purpose Computers
1. Special purpose computer are usually very efficient for the tasks for which they are
specially designed.
2. They are very much less complex than the General-Purpose Computers. The simplicity
of the circuiting stems from the fact that provision is made only for limited facilities.
3. They are very much cheaper than the General-Purpose type since they involve less
components and are less complex.
General-Purpose Computers
General-Purpose computers are computers designed to handle wide range of problems.
Theoretically, a general-purpose computer can be adequate by means of some easily alterable
instructions to handle any problems that can be solved by computation. In practice however,
there are limitations imposed by memory size, speed and the type of input/output devices.
Examples of areas where the general purpose are employed include the following:
Payroll
Banking
Billing
Sales analysis
Cost accounting
Manufacturing scheduling
Inventory control
ALGORITHM
Definition
A set of sequential steps usually written in Ordinary Language to solve a given problem is
called Algorithm.
It may be possible to solve to problem in more than one ways, resulting in more than one
algorithm. The choice of various algorithms depends on the factors like reliability, accuracy
and easy to modify. The most important factor in the choice of algorithm is the time
requirement to execute it, after writing code in High-level language with the help of a computer.
The algorithm which will need the least time when executed is considered the best.
Steps involved in algorithm development
An algorithm can be defined as “a complete, unambiguous, finite number of logical steps for
solving a specific problem “.
Step1. Identification of input: For an algorithm, there are quantities to be supplied called input
and these are fed externally. The input is to be identified first for any specified problem.
Step2: Identification of output: From an algorithm, at least one quantity is produced, called for
any specified problem.
Step3 : Identification the processing operations : All the calculations to be performed in order
to lead to output from the input are to be identified in an orderly manner.
Step4 : Processing Definiteness : The instructions composing the algorithm must be clear and
there should not be any ambiguity in them.
Step5 : Processing Finiteness : If we go through the algorithm, then for all cases, the algorithm
should terminate after a finite number of steps.
Step6 : Possessing Effectiveness : The instructions in the algorithm must be sufficiently basic
and in practice they can be carries out easily.
An algorithm must possess the following properties
1. Finiteness: An algorithm must terminate in a finite number of steps
2. Definiteness: Each step of the algorithm must be precisely and unambiguously stated
3. Effectiveness: Each step must be effective, in the sense that it should be primitive easily
convert able into program statement) can be performed exactly in a finite amount of time.
4. Generality: The algorithm must be complete in itself so that it can be used to solve problems
of a specific type for any input data.
5. Input/output: Each algorithm must take zero, one or more quantities as input data produce
one or more output values. An algorithm can be written in English like sentences or in any
standard representation sometimes, algorithm written in English like languages are called
Pseudo Code.
Example
1. Suppose we want to find the average of three numbers, the algorithm is as follows
Step 1 Read the numbers a, b, c
Step 2 Compute the sum of a, b and c
Step 3 Divide the sum by 3
Step 4 Store the result in variable d
Step 5 Print the value of d
Step 6 End of the program
2. Write an algorithm to calculate the simple interest using the formula. Simple interest = P*N*
R/100.
Where P is principle Amount, N is the number of years and R is the rate of interest.
Step 1: Read the three input quantities’ P, N and R.
Step 2 : Calculate simple interest as
Simple interest = P* N* R/100
Step 3: Print simple interest.
Step 4: Stop.
3. Area of Triangle: Write an algorithm to find the area of the triangle.
Let b, c be the sides of the triangle ABC and A the included angle between the given sides.
Step 1: Input the given elements of the triangle namely sides b, c and angle between the sides
A.
Step 2: Area = (1/2) *b*C* sin A
Step 3: Output the Area
Step 4: Stop.
4. Write an algorithm to find the largest of three numbers X, Y,Z.
Step 1: Read the numbers X,Y,Z.
Step 2: if (X > Y)
Big = X
else BIG = Y
Step 3 : if (BIG < Z)
Step 4: Big = Z
Step 5: Print the largest number i.e. Big
Step 6: Stop.
FLOW CHART
A flow chart is a step by step diagrammatic representation of the logic paths to solve a given
problem. Or A flowchart is visual or graphical representation of an algorithm.
The flowcharts are pictorial representation of the methods to be used to solve a given problem
and help a great deal to analyze the problem and plan its solution in a systematic and orderly
manner. A flowchart when translated in to a proper computer language, results in a complete
program.
Advantages of Flowcharts
1. The flowchart shows the logic of a problem displayed in pictorial fashion which felicitates
easier checking of an algorithm.
2. The Flowchart is good means of communication to other users. It is also a compact means
of recording an algorithm solution to a problem.
3. The flowchart allows the problem solver to break the problem into parts. These parts can be
connected to make master chart.
4. The flowchart is a permanent record of the solution which can be consulted at a later time.
Differences between Algorithm and Flowchart
Algorithm Flowchart
1. A method of representing the step-by-step 1. Flowchart is diagrammatic representation
logical procedure for solving a problem of an algorithm. It is constructed using
different types of boxes and symbols.
2. It contains step-by-step English 2. The flowchart employs a series of blocks
descriptions, each step representing a and arrows, each of which represents a
particular operation leading to solution of particular step in an algorithm
problem
3. These are particularly useful for small 3. These are useful for detailed
problems representations of complicated programs
4. For complex programs, algorithms prove 4. For complex programs, Flowcharts prove
to be Inadequate to be adequate
b. Input and output indicators: Parallelograms are used to represent input and output operations.
Statements like INPUT, READ and PRINT are represented in these Parallelograms.
c. Process Indicators: - Rectangle is used to indicate any set of processing operation such as for
storing arithmetic operations.
d. Decision Makers: The diamond is used for indicating the step of decision making and
therefore known as decision box. Decision boxes are used to test the conditions or ask questions
and depending upon the answers, the appropriate actions are taken by the computer. The
decision box symbol is
e. Flow Lines: Flow lines indicate the direction being followed in the flowchart. In a Flowchart,
every line must have an arrow on it to indicate the direction. The arrows may be in any direction
f. On- Page connectors: Circles are used to join the different parts of a flowchart and these
circles are called on-page connectors. The uses of these connectors give a neat shape to the
flowcharts. Ina complicated problems, a flowchart may run in to several pages. The parts of
the flowchart on different pages are to be joined with each other. The parts to be joined are
indicated by the circle.
PSEUDO CODE
The Pseudo code is neither an algorithm nor a program. It is an abstract form of a program. It
consists of English like statements which perform the specific operations. It is defined for an
algorithm. It does not use any graphical representation. In pseudo code, the program is
represented in terms of words and phrases, but the syntax of program is not strictly followed.
Advantages: * Easy to read, * Easy to understand, * Easy to modify.
Example: Write a pseudo code to perform the basic arithmetic operations.
Read n1, n2
Sum = n1 + n2
Diff = n1 – n2
Mult = n1 * n2
Quot = n1/n2
Print sum, diff, mult, quot
End.
Full-Duplex
In full-duplex (also called duplex), both stations can transmit and receive simultaneously. One
common example of full-duplex communication is the telephone network. When two people
are communicating by a telephone line, both can talk and listen at the same time.
The full-duplex mode is used when communication in both directions is required all the time.
The capacity of the channel, however, must be divided between the two directions.
Transmission mode
The transmission mode of a communication channel refers to the bit-level organization of the
data and the way it is transmitted over the physical medium. The two common modes of
transmission are asynchronous and synchronous transmissions.
Asynchronous transmission
An asynchronous transmission involves the sending of one character (or byte) at a time. To
separate the characters, a start bit and one or more stop bits are added to each end of the
individual 8-bit character code. This mode of transmission is slow and wasteful because the
system must support 11 bits per byte instead of the standard 8 bits.
Synchronous
A synchronous transmission involves the sending of organized blocks of characters, sometimes
called frames or packets. These packet of data are carefully synchronized so that the sending
and receiving devices can distinguish the boundaries of each character. This mode is faster and
more efficient.
Components
A data communications system has five components.
Data Representation
Information today comes in different forms such as
Text
Numbers
Images
Audio, and
Video
Types of network
There are 3 main types of network
1. Local Area Network (LAN): A LAN is usually privately owned and links the devices
in a single office, building, or campus.
2. Wide Area Network. A wide area network (WAN) provides long-distance transmission
of data, image, audio, and video information over large geographic areas that may
comprise a country, a continent, or even the whole world.
3. Metropolitan Area Networks. A metropolitan area network (MAN) is a network with a
size between a LAN and a WAN. It normally covers the area inside a town or a city. It
is designed for customers who need a high-speed connectivity, normally to the Internet,
and have endpoints spread over a city or part of city. A good example of a MAN is the
part of the telephone company network that can provide a high-speed DSL line to the
customer. Another example is the cable TV network that originally was designed for
cable TV, but today can also be used for high-speed data connection to the Internet.
Interconnecting devices
LANs, WANs, and MANs each speak their own language; the process of connecting multiple
dissimilar systems requires very flexible advanced interconnecting devices, these devices
include:
a. Repeater: Repeaters are simple interconnecting devices that connect two identical
cabling segments of a LAN. A repeater accepts weak signals and electrically
regenerates them and then sends the messages back on their way.
b. Bridges: Bridges are more intelligent than repeaters, they go beyond simply
regenerating weak signals. Bridges process network signals and ensure smooth passage
from LAN to LAN and from LAN to WAN.
c. Routers: Routers contain advanced algorithms that allow them to make intelligent
decisions about where a message should go and what path to use for greater efficiency.
d. Gateways: Gateways approach interconnectivity from a complete different angle. These
devices use more of software translation than hardware routing. They are required when
network messages travel between two entirely different systems.
Protocols
In computer networks, communication occurs between entities in different systems. An entity
is anything capable of sending or receiving information. However, two entities cannot simply
send bit streams to each other and expect to be understood. For communication to occur, the
entities must agree on a protocol. A protocol is a set of rules that govern data communications.
A protocol defines what is communicated, how it is communicated, and when it is
communicated.
The sole purpose of protocol is to provide guidance to the communication channels and to
promote harmonious connectivity between the many network components. Protocols work on
the electronic level. They are initiated and controlled by advanced subroutines built into each
NIC.
LANs commonly use one of three communications protocols: CSMA, polling and token
passing.
CSMA
CSMA stands for Carrier Sense Multiple Access. CSMA relies on a share trunk of cabling; the
trunk is a single run of cabling that extends throughout the topology of the LAN. Here is how
the protocol works:
1. Workstation A has a message for workstation B. Workstation A listens to the trunk and
waits until all is clear (Carrier Sensing).
2. When A detects that the trunk is clear, the workstation marks the message with a
destination address and sends it over the trunk. All other workstations continually
monitors the trunk for a message with their address (multiple access).
3. Workstation B finds a match, accepts the message and returns an acknowledgement of
receipt.
Polling
Polling refers on a central controlling node (workstation or file server). The central node polls
each station to determine whether there is a message to be sent. When a sending workstation is
ready, the central node reserves the network channel and the message is sent. Polling is
typically used in a centralized system because this type of protocol relies exclusively on the
intelligence and dexterity of the central controlling node.
Token passing
In the token-passing method, the stations in a network are organized in a logical ring. In other
words, for each station, there is a predecessor and a successor. The predecessor is the station
which is logically before the station in the ring; the successor is the station which is after the
station in the ring. The current station is the one that is accessing the channel now. The right to
this access has been passed from the predecessor to the current station. The right will be passed
to the successor when the current station has no more data to send.
But how is the right to access the channel passed from one station to another? In this method,
a special packet called a token circulates through the ring. The possession of the token gives
the station the right to access the channel and send its data. When a station has some data to
send, it waits until it receives the token from its predecessor. It then holds the token and sends
its data. When the station has no more data to send, it releases the token, passing it to the next
logical station in the ring. The station cannot send data until it receives the token again in the
next round. In this process, when a station receives the token and has no data to send, it just
passes the data to the next station.
TYPES OF TOPOLOGY
Type of Connection
A network is two or more devices connected through links. A link is a communications
pathway that transfers data from one device to another.
Point-to-Point
A point-to-point connection provides a dedicated link between two devices. The entire capacity
of the link is reserved for transmission between those two devices.
Multipoint
A multipoint (also called multidrop) connection is one in which more than two specific devices
share a single link.
Bus Topology
The preceding examples all describe point-to-point connections. A bus topology, on the other
hand, is multipoint. One long cable acts as a backbone to link all the devices in a network.
Nodes are connected to the bus cable by drop lines and taps. A drop line is a connection running
between the device and the main cable. A tap is a connector that either splices into the main
cable or punctures the sheathing of a cable to create a contact with the metallic core.
As a signal travels along the backbone, some of its energy is transformed into heat. Therefore,
it becomes weaker and weaker as it travels farther and farther. For this reason there is a limit
on the number of taps a bus can support and on the distance between those taps.
Advantages
Ease of installation.
Redundancy is eliminated. Only the backbone cable stretches through the entire facility.
Disadvantages
Difficult reconnection and fault isolation.
A fault or break in the bus cable stops all transmission, even between devices on the
same side of the problem.
Bus topology was the one of the first topologies used in the design of early local area networks.
Ring Topology
In a ring topology, each device has a dedicated point-to-point connection with only the two
devices on either side of it. A signal is passed along the ring in one direction, from device to
device, until it reaches its destination. Each device in the ring incorporates a repeater. When a
device receives a signal intended for another device, its repeater regenerates the bits and passes
them along.
Advantages
Relatively easy to install and reconfigure.
Fault isolation is simplified. Generally in a ring, a signal is circulating at all times. If
one device does not receive a signal within a specified period, it can issue an alarm.
The alarm alerts the network operator to the problem and its location.
Disadvantages
Unidirectional traffic.
In a simple ring, a break in the ring (such as a disabled station) can disable the entire
network. This weakness can be solved by using a dual ring or a switch capable of
closing off the break.
Hybrid Topology
A network can be hybrid. For example, we can have a main star topology with each branch
connecting several stations in a bus topology.
HANDS-ON
The students should be introduced to practical in MS Excel such as Formulas, SUM,
Percentage, IF, Nested IF, AND, OR functions etc.
MICROSOFT WORD/WORD PROCESSOR
DEFINITION OF MICROSOFT WORD
This is an application package designed for typing of document and for graphical designing.
Microsoft word belongs to a family called the Microsoft office.
Microsoft office is a program designed by micro-soft companies and has Microsoft attached to
their names. E.g. Microsoft word, Microsoft PowerPoint, Microsoft Excel, Microsoft Access
Etc.
In other words, a word processor is a device or computer program that provides for input,
editing, formatting, and output of text, often with some additional features.
Creating a Document
When a new document is created it has to be formatted to look attractive and presentable. This
determines how the document will look like when finished and printed. The author of the
document could decide to format the document before or after typing.
Steps to Create a blank document
1. Open Word. Or, if Word is already open, select File > New.
2. Select Blank document.
Exercise 1: Type the following passage
New rules to Rationale management;
Foremost: Rationale is the justification of decisions. Rationale models represents the
reasoning that leads to the decisions, including its functionality- and its implementation.
Rationale is critical in two areas: It supports the decisions making and it supports the capture
of knowledge. Rationale includes:
The issues that were addressed
The alternatives that were considered
The decisions that were made to resolve the issues
The criteria that were used to guide decisions
In the context of decision making the rationale improves the quality of decisions by making
decision elements, such as criteria, priorities, and arguments, explicit. In the context of
knowledge capture, the rationale is the most important information in the development process.
Saving a Document
It is good to cultivate the habit of saving one’s work periodically while typing to avoid loss of
information in case of an interrupted power supply.
To save, follow the steps below:
1. Select File from the Menu
2. Select Save As. A dialogue box appears as shown below:
3. Select the location to save e.g. desktop, documents etc.
A
drop cap (dropped capital) is a large capital letter used as a decorative element at the
beginning of a paragraph or section. The size of a drop cap is usually two or more
lines.
Add a drop cap
1. Select the first character of a paragraph.
2. Go to INSERT > Drop Cap.
3. Select the drop cap option you want.
To create a drop cap that fits within your paragraph, select Dropped.
To create a drop cap that is in the margin, outside of your paragraph, select In
margin.
MAIL MERGE
Mail merge is an MS word feature that lets you create letters for a number of people without
typing the original letter more than once. The letter is saved in a separate file called form file.
A letter form file contains all the formatting information, text, and graphics you want to be
common to each other. Next you create the data file that contains all the names and addresses
that should go with the letter. Finally, in order to create the complete letters, you merge the
form file with the data file.
LABORATORY EXERCISE
1. The tutor should guide the students in the computer Laboratory on how to generate and
insert automatic table of contents in MS word.
INTRODUCTION TO BASIC
The original BASIC was first developed at Dartmouth College by John Kemeny, Mary Keller,
and Thomas Kurtz and introduced on May 1, 1964. BASIC is short for Beginner’s All-purpose
Symbolic Instruction Code and is an easy-to-understand programming language that was
popular during 1970 – 1980. Today, BASIC is not used to develop programs, but is sometimes
used to help teach the fundamentals of programming.
The BASIC language was originally designed as a simplified version of FORTRAN for use in
teaching programming. From the simple beginnings, the language has grown to become a very
popular multi-purpose language available on a wide variety of machines.
There are many versions of the Basic language:
1. Ms-Basic
2. Gee Whiz-Basic (GW- Basic)
3. QBasic-Quick Basic
4. Just BASIC (JBasic)
5. BASIC Plus
6. BASIC A
7. Turbo BASIC
INSTALLING AND RUNNING JBASIC
Download it here: https://justbasic.com/download.html
ELEMENTS OF BASIC
Character set
BASIC has the character set consisting of the following elements:
1. Alphabets: A, B, C,….Z (small or capital)
2. Digits: 0, 1, 2……..,9 and
3. Special characters: + – * / ( ) . , $ ; ,: ,= ,> ,< , ^
Variables
The quantity which may change its values during the execution of the program is called the
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."
In QBASIC, variables are also of two types:
i. Numeric variable: Numeric variable can assume numeric value and is represented
by an alphabet or an alphabet followed by another alphabet or digit. For example
A, C, A2, ABC, A6 etc., represent numeric variables.
ii. String/character variable: A string variable is represented by an alphabet
followed by dollar ($) sign. It should be kept in mind that while constructing the
string variable, dollar ($) should be the last character. For example, B1$, NAME$,
BOOK1$, etc. are valid string variables.
Constants
A quantity in a computer program which does not change its value during the execution of
the program is called a constant. BASIC allows the following constants:
i. Numeric constant: The numeric constant is one that is formed by a sequence
of digits 0, 1, 2,…..9 and may include a decimal point. A numeric constant may
be an integer or a real number. 383, +57, 0, -6.2 and 6.15E4 are valid numeric
constants.
ii. String/character constant: A string constant consists of a sequence of
characters which must be enclosed by a quotation.
Operator and Operands
Operands are the data or variables on which mathematical, logical and string operations
take place.
Operators are the symbols, which are used in arithmetic operations, logical expressions,
and string expressions.
Expression
An expression can be a string, or numeric constant, a variable or a combination of constants,
variables with operators which returns a single value.
Statements
A statement is a set of instructions written using keywords or commands of BASIC. Every
programming language uses keywords as a statement with certain syntax.
BASIC KEYWORDS
1. Remark Statement (REM): This is a remark. It does not affect the program in terms
of instruction or command line. REM: It is used in explaining what the program is all
about.
Example,
10 REM. Program to calculate average of numbers.
This statement will appear as comment on the screen
2. Assignment Statement: This keyword is used in assigning values to variables, e.g.
READ, DATA, LET, INPUT.
READ statement: This is a statement used in giving values to variables. Usually
READ statement has DATA statement with it.
Example:
10 REM PROGRAM TO SUM NUMBERS
20 READ X
30 DATA 2
40 READ Y
50 DATA 3
60 READ Z
70 DATA 5
80 SUM=X+Y+Z
90 PRINT "The sum is:", SUM
LET statement: This statement is used in attaching strings of fixed characters and
numeric data in BASIC.
Examples,
10 REM PROGRAM TO SUM NUMBERS
20 READ X
30 DATA 2
40 READ Y
50 DATA 3
60 READ Z
70 DATA 5
80 LET SUM=X+Y+Z
90 PRINT "The sum is:", SUM
INPUT/ PRINT statements: INPUT statement is used assigning values to variables.
PRINT statement is used displaying values to the screen. The PRINT statement is
usually followed by a list of items to be displayed and each item is separated by a
comma (,) or semi-colon (;).
Example 1:
10 REM PROGRAM TO SUM NUMBERS
20 input "Enter first number:"; X
30 INPUT "Enter second number:"; Y
40 INPUT "Enter third number:"; Z
50 PRINT X, Y, Z
60 PRINT "X=",X,"Y=",Y,"Z=",Z
70 LET SUM=X+Y+Z
80 PRINT "The sum is:", SUM
Example 2:
PRINT 512 + 478
Program output:
990
If you enclose the expression with quotation marks, the expression becomes a string and
isn't evaluated. For example:
PRINT "512 + 478"
Output:
512 + 478
To place World onto the previous line, place a semi-colon after PRINT "Hello".
PRINT "Hello";
PRINT "World"
Output:
HelloWorld
Also, if you put a comma instead of a semi-colon on the first line, the program will insert
spaces between the two words.
PRINT "Hello",
PRINT "World"
Output:
Hello World
Program Terminator: These keywords are used to terminate the program, e.g. STOP
and END.
a) STOP statement: This statement is used to terminate a program.
b) END statement: This statement is used to terminate a program.
Example:
10 REM PROGRAM TO SUM NUMBERS
20 input "Enter first number:"; X
30 INPUT "Enter second number:"; Y
40 INPUT "Enter third number:"; Z
50 PRINT X, Y, Z
60 PRINT "X=",X,"Y=",Y,"Z=",Z
70 LET SUM=X+Y+Z
80 PRINT "The sum is:", SUM
90 STOP
Assignments
1. Write a BASIC program to calculate the product of three numbers
2. Write a program to calculate the area of a circle. (Area= πr2)
3. Write a program to calculate simple interest
4. Write a BASIC program to calculate the sum of two numbers
5. Write a BASIC program to find the average of 3 Numbers
6. Write a BASIC program to calculate the area of a triangle with base
7. Write a program to find the product of four numbers using the ‘LET’ statement
8. Write a program to calculate the average of five numbers using the ‘INPUT’ statement
VARIABLES
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."
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
EXPRESSIONS
If you pass an expression to a variable, the expression is evaluated and the variable is set to
that value.
x = 500 + (10 * 7)
PRINT x
Output:
570
STRINGS
If you add a dollar sign ($) to the end of a variable, the variable is a string.
X$ = "Hello World!"
PRINT X$
Output:
Hello World!
INPUT data$
PRINT data$
When this program is executed, the INPUT command displays a question mark, followed by a
blinking cursor. And when you enter text, the program stores that text into the variable data$,
which is printed to the screen.
To receive a number, use a non-string variable.
INPUT number
PRINT number
PRINT text$
PRINT text$
CONTROL STRUCTURE
Control structure/statements are used in program to direct the order of execution of the
program. Normally, statements in a program are executed one after the other in the order in
which they’re written. This process is called sequential execution. Various Basic statements,
enable you to specify that the next statement to execute is not necessarily the next one in
sequence. This is called transfer of control. Structured programs are clearer, easier to debug
and modify, and more likely to be bug free in the first place.
Programs could be written in terms of only three control statements:
the selection statement
the Jump statement
the repetition statement.
SELECTION STATEMENT
The selection structure are known as decision making structures. It require that the programmer
specify one or more conditions to be evaluated or tested by the program, along with a statement
or statements to be executed if the condition is determined to be true, and optionally, other
statements to be executed if the condition is determined to be false.
There are three basic types of selection statements:
i. If-then (Single-Selection) Statement
The if statement either performs (selects) an action, if a condition is true, or skips it, if the
condition is false. The if-then statement is the simplest form of control statement, frequently
used in decision making and changing the control flow of the program execution.
Example:
x=5
IF x = 5 THEN PRINT "x equals 5"
Since X does equal 5 in this case, the program outputs:
x equals 5
Expression signs
You can also enter the following statements, instead of the equals sign:
x < 5 (x is less than 5)
x > 5 (x is greater than 5)
Run the following:
x = 16
IF (x > 5) THEN PRINT "x is greater than 5"
Output:
x is greater than 5
You can also combine the signs like this:
x <= 5 (x is less than or equal to 5)
x >= 5 (x is greater than or equal to 5)
x <> 5 (x does not equal 5)
Run the following example:
CLS
x=5
IF (x >= 5) THEN PRINT "x is greater than or equal to 5"
IF (x <= 5) THEN PRINT "x is less than or equal to 5"
IF (x <> 5) THEN PRINT "x does not equal 5"
Output:
x is greater than or equal to 5
x is less than or equal to 5
ii. if-then-else (Double Selection) Statement
The if-then-else statement performs an action if a condition is true and performs a different
action if the condition is false. The if-then single-selection statement performs an indicated
action only when the condition is true; otherwise, the action is skipped. The if-then-else double-
selection statement allows you to specify an action to perform when the condition is true and a
different action when the condition is false.
Using the ELSE command, you can have the program perform a different action if the statement
is false.
x=3
IF x = 5 THEN PRINT "Yes" ELSE PRINT "No"
Output
No
END IF
END IF allows you to have multiple commands after the IF...THEN statement, but they must
start on the line after the IF statement. END IF should appear right after the list of commands.
x=5
IF (x = 5) THEN
INPUT a$
PRINT a$
END IF
Output:
32
Example 1:
x=6
IF (x = 5) THEN
PRINT "Statement 1 is true"
ELSEIF (x = 6) THEN
PRINT "Statement 2 is true"
END IF
Output:
Statement 2 is true
Example 2:
You can have multiple ELSEIF commands, along with ELSE.
x=8
IF (x = 5) THEN
PRINT "Statement 1 is true"
ELSEIF (x = 6) THEN
PRINT "Statement 2 is true"
ELSEIF (x = 7) THEN
PRINT "Statement 3 is true"
ELSE
PRINT "No above statements are true"
END IF
Output:
No above statements are true
Strings in IF...THEN
So far in this chapter, we've only been dealing with numbers, but you can also use strings with
the IF...THEN command.
x$ = "Hello"
IF (x$ = "Hello" OR x$ = "World") THEN PRINT x$
Output:
Hello
Output:
Hello World
JUMP STATEMENT
The GOTO and GOSUB commands enables you to jump to certain positions in your program.
Labels 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 <label>
Example
Run the following example program:
PRINT "1"
GOTO TheLabel
PRINT "2"
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.
PRINT "1"
GOSUB TheLabel
PRINT "2"
END
TheLabel:
PRINT "3"
RETURN
LINE NUMBERS
"Line numbers" can be used as labels.
PRINT "1"
GOTO 10
PRINT "2"
10 PRINT "3" (Notice the line number)
You can also write the program like this:
10 PRINT "1"
20 GOTO 40
30 PRINT "2"
40 PRINT "3"
GUESSING GAME
The following is a simple guessing game:
CLS
start:
PRINT "Guess a number between 1 and 10: ";
INPUT num
IF (num < 1 OR num > 10) THEN
PRINT "That is not between 1 and 10"
GOTO start
END IF
IF (num = 6) THEN
PRINT "Correct!!!"
ELSE
PRINT "Try again"
PRINT
GOTO start
END IF
IF...GOTO
This program uses IF...GOTO to create a loop:
x = 10
start:
PRINT x
x = x + 1 (This adds 1 to x)
IF x < 15 THEN GOTO start
Output:
10
11
12
13
14
WHILE...WEND
The WHILE...WEND commands continue a loop until a specified expression is false.
To use WHILE...WEND:
1. Place an expression after WHILE
2. Enter a list of commands
3. Place WEND at the end
Example:
x = 10
WHILE x < 15
PRINT x
x=x+1
WEND
DO...LOOP
DO...LOOP is exactly the same as WHILE...WEND, except it has at least two slight
advantages.
With DO...LOOP you can:
1. Loop until an expression is true
2. Loop at least one time regardless of whether the expression is true or not.
To use DO...LOOP:
1. Specify whether the loop continues "while" the expression is true or "until" the
expression is true, using the WHILE and UNTIL statements, respectively.
2. Place an expression after WHILE/UNTIL
3. Enter a list of commands
4. Place LOOP at the end
The following uses the WHILE statement:
x = 10
DO WHILE x < 15
PRINT x
x=x+1
LOOP
If you place the expression at the end of the loop instead, the program goes through the loop at
least once.
x = 32
DO
PRINT x
x=x+1
LOOP WHILE 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.
Example:
FOR x = 1 TO 5
PRINT x
NEXT x
Output:
1
2
3
4
5
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
PRINT x
NEXT x
Output:
1
3
5
STOPPING LOOPS
To stop a loop prematurely, use the EXIT command, followed by either FOR or DO.
Example:
FOR x = 1 TO 5
PRINT x
IF (x = 3) THEN EXIT FOR
NEXT x
Output:
1
2
3
(NOTE: This command only works with the DO...LOOP and FOR...NEXT commands, not
with WHILE...WEND or IF...GOTO.)
MATHEMATICS FUNCTIONS
Basic 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.
PRINT SQR(1)
PRINT SQR(4)
PRINT SQR(9)
PRINT SQR(16)
PRINT 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).
PRINT ABS(12)
PRINT ABS(-12)
Output:
12
12
COS, SIN, TAN, and ATN
You can do the following trigonometric functions in QBasic:
COS (Cosine)
SIN (Sine)
TAN (Tangent)
ATN (Arctangent, inverse of TAN)
Example:
CONST PI = 3.141593
PRINT COS(PI / 4)
PRINT SIN(PI / 3)
PRINT TAN(-PI / 2)
PRINT ATN(TAN(-PI / 2))
Output:
.7071067
.8660254
6137956
1.570796 (Same as PI / 2)
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 DIM (dimension) command.
The following example does not use arrays:
a=2
b=4
c=6
d=8
e = 10
PRINT a, b, c, d, e
Output:
2 4 6 8 10
This uses an array called vars, which contains 5 variables:
DIM vars(5)
Each of these are separate variables:
vars(1) = 2
vars(2) = 4
vars(3) = 6
vars(4) = 8
vars(5) = 10
PRINT vars(1), vars(2), vars(3), vars(4), vars(5)
Output:
2 4 6 8 10
Output:
2 4 6 8 10
STRINGS
You can also create an array of string variables.
DIM vars$(5)
vars$(1) = "Two"
vars$(2) = "Four"
vars$(3) = "Six"
vars$(4) = "Eight"
vars$(5) = "Ten"
PRINT vars$(1), vars$(2), vars$(3), vars$(4), vars$(5)
Output:
Two Four Six Eight Ten
SUB GetText
PRINT "Enter some text:";
INPUT text$
PRINT "The text you entered was: "; text$
END SUB
FUNCTIONS
A function is the same as a subroutine, except it returns a value. Also, you must leave out the
CALL command.
To return a value, set a variable with the same name as the function.
PRINT Add(10, 7)
Output:
17
Since a function can return a value, the name of the function can end with special characters
(see Variable types, Using special characters).
' Notice the dollar sign ($) after "Add." It means
' the function returns a string.
Output:
HelloWorld