0% found this document useful (0 votes)
98 views111 pages

New Introduction To Computer

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views111 pages

New Introduction To Computer

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 111

Introduction to Computer

‫ نال‬1301
Chapter 1
Introduction to Computer Science
What is a Computer ?
A computer is an electronic device, accepts data (input) from the user, Process the
data into information, Produce the result (output). Stores the results for future
use.

 Data: Data is a collection of unprocessed items, which can include


text, numbers, images, audio, and video.
 Information: That is conveying meaning and useful to people.

3
What is the information processingcycle?
information processing cycle consists of five processing elements, they are:-

 Input
 Process
 Output
 Storage
 Communication

4
Advantages of Using Computers

• Speed: When data, instructions, and information flow along electronic circuits in a
computer, they travel at incredibly fast speeds. Many computers process billions or
trillions of operations in a single second.
• Reliability: The electronic components in modern computers are dependable and
reliable because they rarely break or fail.
• Consistency: Given the same input and processes, a computer will produce the same
results consistently. Computers generate error-free results, provided the input is correct
and the instructions work.
• Storage: Computers store enormous amounts of data and make this data available for
processing anytime it is needed.
• Communications: Most computers today can communicate with other computers, often
wirelessly. Computers allow users to communicate with one another.

5
Disadvantages of Using Computers

• Violation of Privacy: In many instances, where personal and confidential records stored on computers were not
protected properly, individuals have found their privacy violated and identitiesstolen.

• Public Safety: Adults, teens, and children around the world are using computers to share publicly their photos,
videos, journals, music, and other personal information. Some of these unsuspecting, innocent computer users
have fallen victim to crimes committed by dangerous strangers.

• Impact on Labor Force: Although computers have improved productivity and created an entire industry with
hundreds of thousands of new jobs, the skills of millions of employees have been replaced by computers. Thus, it is
crucial that workers keep their education up-to-date. A sepa- rate impact on the labor force is that some
companies are outsourcing jobs to foreign countries instead of keeping their homeland labor force employed.

6
Disadvantages of Using Computers

• Health Risks: Prolonged or improper computer use can lead to health injuries or disorders.
Computer users can protect themselves from health risks through proper workplace design, good
posture while at the computer, and appropriately spaced work breaks.

• Impact on Environment: Computer manufacturing processes and computer waste are depleting
natural resources and polluting the environment. Green computing involves reducing the
electricity consumed and environmental waste generated when using a computer. Strategies that
support green computing include recycling, regulating manufacturing processes, extending the
life of computers, and immediately donating or properly disposing of replaced computers.

7
Exercise
A. Write short answers for the following.
1) What is computer?
2) What are the five processing elements in information processing cycle of computer?
3) What are the advantages of using Computers
4) What are the disadvantages of using Computers

8
Chapter 2
Computer Parts and Classification
Parts of computers:-
A computer system consists of three main parts, they are:

1) Hardware 2) Software 3) Communication System

1) Hardware is the electronic and mechanical parts of a computer system. It is everything you can
touch and see

Examples: Monitor, hard drive, computer cables, keyboard, mouse, modem, printer, etc

2) Software are programs & applications. It Consists of a series of instructions that tells the
computer what to do with data.

3) Communication system (Network ) is a collection of computers and devices connected via


communications media

10
10
Parts of computers:- Hardware

 Motherboard connects all parts and components of a computer to each other and it is
heart of the computer. Motherboard is the central printed circuit board (PCB) in some
complex electronic systems.
Processors
 Central Processing Unit (CPU):
CPU Performs all types of data processing operations.
 Graphics Processing Unit (GPU):
GPU designed to handle a variety of specialized tasks such as displaying
3D images and encrypting data. Powerful GPUs are a standard feature
in gaming computers to support fast processing of virtual
environments.
 Accelerated Processing Unit (APU):
APU houses and offers the combination of CPU and GPU into one
component called APU.
Classification of Computers
We can classify the computeís into the following 3 categoíies:

Classifications of Computeís System:-


1. On the Basis of Size and Capacity, [Supeícomputeí,

Mainfíame, Mini, and Micío Computeí].

2. On the Basis of Puíposes, [Geneíal and Special Puípose].

3. On the Basis of Haídwaíe Design and ľype [Analog, Digital,

and Hybíid Computeí].


Computers on the Basisof SizeandCapacity

1. Supercomputers
• The fastest, most powerful and most expensive computer
• Used for applications requiring complex mathematical
calculations
• Fastest supercomputer can perform more than one trillion
calculations per second

• Applications:
 The uses of supercomputers are dedicated to –
• In research and study of energy and nuclear weapons and
designing the aircraft, airplanes, and flight simulators.
Computers on the Basisof SizeandCapacity
2. Mainframe Computers
• Very powerful and expensive computer that supports thousands
of computers
• Used in large organizations
• Users access the mainframe’s resources through dump or
intelligent terminal

• Applications:
• Mainframe computers are mainly used by departmental and
commercial organizations like Banks, Companies, Scientific
research center
Computers on the Basisof SizeandCapacity
3. Minicomputers
• First released in 1960s
• Can handle much more input and output than personal computers
• Can handle hundreds of users at the same time
• Applications:
• Minicomputers were used for scientific and engineering computations,
business transaction processing, file handling, and database
management.
Computers on the Basisof SizeandCapacity

4. Micro Computer
• A microcomputer is a small, relatively inexpensive computer with a microprocessor as
its central processing unit (CPU).
• Microcomputers became popular in the 1970s and 1980s with the advent
of increasingly powerful microprocessors.

• Applications:
 The uses of Microcomputer –
• PC is being widely used in many fields like home, office, data
collection, business, education, entertainment, publishing, etc.
• Examples:
• Desktops, tablets, smartphones, and Laptops.

The fast development of microcomputers with technology. As a


result, today, microcomputers coming in the form of a book, a
phone, and even a clock in the name of a digital clock.
Computers on the BasisPurpose

• 1. General Purpose
• General computers can do various everyday tasks.
• The size, storage capacity, and cost of such computers are mainly less.
• The ability of these computers is limited in performing specialized tasks. it has
versatility and useful for serving people’s basic needs at home or in the
workplace in the environment.

• Examples:
• Desktops, laptops, smartphones, and tablets are used on daily basis for general purposes.
Computers on the BasisPurpose

• 2. Special Purpose
• These computers are designed to perform a particular or specialized task.
• The size, storage capacity, and cost of such computers mainly depend on the nature
and size of the work.
• The function of these computers is consistent with any particular task.

• The special computer needs specific processors and input and devices to conduct
work efficiently.

• Examples:
• Automatic teller machines (ATM),
• Washing machines,
• Surveillance equipment,
• Traffic-control computers,
Computers on the Basisof Hardware Design and Data Handling

• 1. Analog Computer
• An analog computer performs tasks using continuous data (the physical amount
that changes continuously).
• Analog computers are used primarily to measure physical units like the voltage,
pressure, electric current, temperature, and convert them into digits.

• Examples:
• A simple clock, the vehicle’s speedometer, Voltmeter, etc. are examples of
analog computing.
Computers on the Basisof Hardware Design and Data Handling

• 2. Digital Computer
• This computer is the computer that calculates the number for processing the
data.
• It can perform arithmetic operations such as addition, occurrence,
subtraction, multiplication, or division and all types of logical(mathematical)
operations.
• Examples
• The desktop or Laptop at our home is one the common and best example of a
digital computer.
Exercise
(A) Define the following.
1) Hardware
2) Software
3) Communications Devices
4) Motherboard
5) Central Processing Unit
6) Graphics Processing Unit
7) Accelerated Processing Unit

(B) Give the full forms for the following.


1) CPU 2) GPU 3) APU
Exercise
Choose the best option from the following.
1. Monitor is a .
a) Hardware b) Software
c) Both

2. is the central printed circuit board (PCB) in some complex electronic systems.
a) Motherboard b) ROM
c) Keyboard

Q1. What are the differences between computers on the Basis of Size and Capacity?
Q2. Define the following along with examples:
1. Supercomputer
2. Mainframe
3. Minicomputer
4. Microcomputer
Chapter 3
Numbers System
Definition of Number Systems

A number system is defined as the representation of numbers by


using digits or other symbols in a consistent manner.
The value of any digit in a number can be determined by a digit, its
position in the number, and the base of the number system.
The number systems also help in converting one number system
to another.
Number systems helps in representing the numbers in a small
symbol set.
Types of Number Systems

There are different types of number systems in which the four


main types are:
1. Binary number system (Base - 2)
2. Octal number system (Base - 8)
3. Decimal number system (Base - 10)
4. Hexadecimal number system (Base - 16)
We will study each of these systems one by one in detail.
Octal Number System

The octal number system uses eight digits: 0,1,2,3,4,5,6,7


with the base of 8.
The advantage of this system is that it has lesser digits when compared
to several other systems, hence, there would be fewer computational
errors
For example: 358, 9238, 14183588 are some examples of numbers in
the octal number system.
Decimal Number System

The decimal number system uses ten digits:


0,1,2,3,4,5,6,7,8 and 9 with the base number as 10

The decimal number system is the system that we generally


use to represent numbers in real life. If any number is
represented without a base, it means that its base is 10.

For example: 72310, 524710, 3210, 983710 are some examples


of numbers in the decimal number system.
Conversion of Binary Number Systems to
Decimal Number Systems
To convert a number from the binary system to the decimal system, we
use the following steps.
Example:1
Convert (100111)2 into the decimal system.
Solution:
Step 1: Identify the base of the given number. Here, the base of (1001112100111)2 is 2.
Step 2: Multiply each digit of the given number, starting from the rightmost digit, with the exponents of the base. The
exponents should start with 0 and increase by 1 every time as we move from right to left.
Since the base here is 2, we multiply the digits of the given
number by 20, 21, 22 , and so on from right to left.
Step 3: We just simplify each of the above products and add
them.
Here, the sum is the equivalent number in the decimal number
system of the given number. Or, we can use the following steps to
make this process simplified.
100111=(1×25)+(0×24)+(0×23)+(1×22)+(1×21)+(1×20)
=(1×32)+(0×16)+(0×8)+(1×4)+(1×2)+(1×1)
=32+0+0+4+2+1=39
Example:2
Convert (111111)2 into the decimal system.

111111=(1×25)+(1×24)+(1×23)+(1×22)+(1×21)+(1×20)
=(1×32)+(1×16)+(1×8)+(1×4)+(1×2) +(1×1)
=32+16+8+4+2+1=63
Conversion of Decimal Number System to Binary Number
System
To convert a number from the decimal number system to binary
number system, we use the following steps.
Example:
Convert (4320104320)10 into the binary system.
Solution:
Step 1: Identify the base of the required number. Since we have to convert the given number into the binary
system, the base of the required number is 2.
Step 2: Divide the given number by the base of the required number and note down the quotient and the
remainder in the quotient-remainder form. Repeat this process (dividing the quotient again by the base) until we
get the quotient to be less than the base.
Example : Convert (17)10 into the binary system base- 2.
Solution: We divide 17 by 2 and note down the result and the remainder. We will repeat this process for every quotient until we get a quotient that is less than 2.

Thus, (160)10=(10100000)2
Binary Addition
It is a key for binary subtraction, multiplication, division.
There are four rules of binary addition.
Examples

Perform binary addition on the following numbers


Exercises 1 : Short Questions

1. What are Number Systems with Examples?


2. Why are the Uses of Each Number Systems?
3. What are the 4 Types of Number Systems?
4. What is the Importance of Number Systems?

Exercises 2 : Choose the correct answer


Q1: Which of the following systems uses ten digits?
a) Binary number system
b) Octal number system
c) Decimal number system
d) Hexadecimal number system
Exercises 3 : Conversion of Number Systems

1. Convert (001111)2 into the decimal system.


2. Convert (00000)2 into the decimal system.
3. Convert (010101)2 into the decimal system.
4. Convert (101010)2 into the decimal system.
5. Convert (16)10 into the binary system.
6. Convert (32)10 into the binary system.
7. Convert (128)10 into the binary system.
8. Convert (18)10 into the binary system.
Exercises 3 : Binary Addition

Perform binary addition on the following numbers

1. 101 + 111 =

2. 111 + 111 =

3. 1010 + 1010 =

4. 11101 + 1010 =

5. 11111 + 11111 =
Chapter 4
Computer System Organization and
Memory Unit
Computer Systems

A computer system is a particular


type of system that its primary A computer system is composed
purpose is that of performing of a Central Processing Unit
computations. Before the time of (Control Unit and Arithmetic &
the electronic computers, a Logic Unit), Memory and
computer was a person that Input/Output subsystems.
performed computations.
Computer components
Central Processing Unit (CPU)
 The Central Processing Unit (CPU): is composed of a Control Unit and an
Arithmetic & Logic Unit.
• The Control Unit (CU): controls the different components of the system and
it is responsible for fetching, decoding and executing the instructions of a
program.
• The Arithmetic & Logic Unit (ALU): is performs arithmetic and logical
operations such as addition, division, comparison, etc.

Control Unit (CU)


• The Control Unit is the part of the CPU that fetches (reads) instructions
from memory.
• Each instruction is decoded to determine what exactly it is supposed to
do.

• Once decoded, each instruction is executed.


Arithmetic & Logic Unit(ALU)
The Arithmetic & Logic Unit (ALU) performs
the arithmetic operations as well as the
logical operations.

The arithmetic operations include addition,


subtraction, multiplication and division.

The logical operations are commonly used to


compare values and determine whether they
are greater, lesser or equal to one another.

These operations are normally carried out


with registers that are part of the CPU.
Input Devices
• Keyboard

Laptop keyboard Virtualkeyboard Thumb keyboard

• Pointing Devices:

Optical mouse Touch pad Multitouch screen Game controller

29
Input Devices

Stylus Microphone Digital camera

Scanner Barcodereader
30
Input Devices

RFIDreader (OCR)Wand reader

Optical-mark recognition (OMR)


31
Output Devices

Monitor Speakers Headphones

Digital projector
Printer 32
Components of Computer:
•Central Processing Unit
•Buses
•Memory Unit
 Central Processing Unit
The part of the Computer that performs the bulk of data
processing operations is called the Central Processing Unit
and is referred to as the CPU.
 Memory or Storage Unit:
Memory unit stores all the data and the instructions required for processing.
This unit can store instructions, data and intermediate results.
Main Memory Devices
1. Random-Access Memory (RAM)
• Usually called the main memory
• It can be read and written to
• It does not store information permanently (Volatile , when it is powered off, the
stored information are gone)
• Information stored in it can be accessed in any order at equal time periods
(hence the name random access)
• Information is accessed by an address that specifies the exact location of the
piece of information in the RAM.
Primary storage Devices
2. ROM (Read-Only-Memory)
A read-only-memory, non-volatile i.e. stores information permanently
Has random access of stored information
Used to store the information required to startup the computer
3. Cache memory
A very fast type of RAM that is used to store information that is most frequently
or recently used by the computer
Recent computers have 2-levels of cache; the first level is faster but smaller in size
(usually called internal cache), and the second level is slower but larger in size
(external cache).
Secondary storage Devices
Secondary memory is also called secondary storage, external memory or non-
volatile. Secondary storage is a non-volatile memory which holds data and programs even
after electric power to the computer system has been turned off.. Data/Information is
stored permanently.
• The kinds of secondary media are hard disks, solid-state storage, eMMC, USB, cloud
storage etc.

1. Hard Disk Drive (HDD)


Hard disks are typically used to store programs and very large data files. Using rigid metallic platters
and read/write heads that move across the platters

2. Solid-state drive (SSD)


solid-state storage does not have any moving parts, is more reliable, and requires less power. It saves
data and information electronically instead of magnetically or optical. SSD is faster than HDD.
Secondary Memory Devices

3. embedded Multi-Media Card (eMMC)

4. External hard disk

5. Flash memory/USB

6. Cloud storage: Data or files are said to be stored in cloud when

they are stored in a remote server which is easily accessible from

anywhere with internet access.


Exercises
(A)
1) Write down at least four input devices.
2) Write down a few examples of output devices.
3) Write down the types of primary storage devices.
4) Write down the types of secondary storage devices.
5) How many types of primary storage devices are there?
6) Which memory is also called as volatile memory?
7) What is the main function of Random Access Memory?
8) Write down any three secondary storage devices.

(B) Give the full forms for the following.


1) CU 2) ALU 3) RAM 4) ROM 5) HDD 6) SSD 7) eMMC
Exercises
(C) Define the following:
1) RAM (Random access memory)
2) ROM (Read-only memory)
3) Cache memory
4) Secondary memory
5) HDD (Hard disk drive)
6) SSD (Solid-state drive)
7) Cloud storage
Exercises
(D) Choose the best option from the following.
1. Printer is an device .
a) output b) input
c) Both
2. Keyboard is an example of device.
a) output b) input
c) network
3. One of the following is an output device .
a) RFID b) Printer
c) Mouse
4. RAM is a memory.
a) volatile b) Non-volatile
c) both
5. Hard disk memory.
a) volatile b) Non-volatile
c) both
Chapter 5

Software

41
Software
 Software is the programs and data that a computer
uses.
 Programs are lists of instructions for the
processor
 Data can be any information that a
program needs:
character data, numerical data, image
data, audio
data, etc.
 Both programs and data are saved in
computer memory in the same way.
42
Typesof Software

 Computer software is divided into three main categories:

1. Systems software

2. Applications software

3. Programming languages
System Software

 System software manages computer resources


and makes computers easier to use

 Operating System is a system software that manage


computer resources and control the running of user
programs

 Utility Programs allow the user to perform


maintenance tasks usually related to managing a
computer, its devices or its programs
Applications software:
An applications software enables a computer user to
do a particular task.

Programming languages(PL):
Programming languages are one kind of computer
language, and are used in computer programming to
implement algorithms. Most programming languages
consist of instructions for computers.
Virtual Machine

• The set of services and resources created by the


software and seen by the user is called a virtual
machine.
• The programmer should not have to know about
registers, addition circuits, memory addresses etc. but
instead should see a virtual machine that
“understands” the symbols + and =.
Software components

Systems Application Programming


Software Software languages
- -Word -- Assembly
Operatin processors -- Visual Basic
g system. - Game programs -- Pascal
- - Spreadsheets -- C++
Networkin -Data base -- Java
g system systems
-- Python
- Utility programs -Graphics
- Web site server. programs
- Web browsers
47
Operating Systems(OS)
 It is a group of programs that coordinates the
operation of all the hardware and software
components of the computer system.
 Among the jobs done by an OS are:
 Schedule the jobs to be processed by the CPU
Manage the resources such as memory, I/O, data
transfer etc.
Examples:
 Desktop operating systems :
MS-DOS, MS Windows, Unix, Solaris, Linux, and macOS.
 Mobile operating systems:
iOS, Android, HarmonyOS, Windows phone and Symbian
48
Operating SystemsComponents

 Memory Management
 Allocate memory
 Ensures processes stay memory boundaries
 Controlling virtual memory
 I/0 System
 Communicates with peripherals and hardware
components
 Co-ordinates i/o systems such as interrupts and
direct memory access
Operating SystemsComponents

 Files system
 Organises and accesses files
 Maintains on a multi-user system user file quotas
 Controls file/record access

 Application Program Interface


 Provides systems services for applications
 An interface between the applications and the operating
system.
Operating SystemsComponents

 User interface
 Allows the user access to programs
 Allows the user to view and change system
settings.
 A consistent interface between the user and the
operating system.

51
Exercise
(A) Write short answers for the following.

1) What is data?
2) What is an operating system?
3) Which computer software enables a computer user to do a
particular task?
4) What are the jobs of an operating system?
5) What are the functions of file system?
6) Write three(3) examples of Operating Systems.
7) Write three(3) examples of Application software.
8) Write any two(2) jobs done by Operating System(OS).
Exercise
(B) Define the following.
1) Software
2) System Software
3) Programming Language

(C) What does OS stand for?

(D) Do as directed.
1) Draw a table to explain different software components?
2) Draw chart to explain the functioning of operating
system?
Exercise: Choose the best option from the following.

1. Computer software is divided into ................ maincategories.


a) 3 b) 2
c) 1 d) 5
2. ………………………software manages computer resources and makes computers easier
to use.
a) Application b) system
c) Programming d) monitor

3. MS Windows is an example of ……………………………………


a) application software b) Programming language
c) operating system d) Script language
4. OS stands for ……………………………………
a) Open Software b) Operating System
c) Oracle System d) Outsource System
Exercise: Determine whether the given statements are True or False.

• Software is the programs and data that a computer uses. TRUE/ FALSE

• java is an example of Systems software. TRUE/ FALSE

• Web browsers are the example of programming languages. TRUE/ FALSE

• Networking system is the example of Systems software. TRUE/ FALSE

• Programs are lists of instructions for the processor. TRUE/ FALSE

• Linux is not example of operating system. TRUE/ FALSE


Chapter 6
Introduction to Computer Networking
Network Definition
A network can be defined as two or more computers connected
together in such a way that they can share resources.
The purpose of a network is to share resources.

Two computers connected together via cable. This is the simplest form of
computer network.
Advantages of networking
• Connectivity and Communication
• Data Sharing
• Hardware Sharing
• Internet Access
• Internet Access Sharing
• Data Security and Management
• Performance Enhancement and Balancing
• Entertainment
Fundamental Network Classifications
Local Area Networks (LANs):
• A local area network (LAN) is a computer network covering a small
geographic area, like a home, office, or group of buildings The area is
not exceeding 10 KM.
Fundamental Network Classifications
Wide Area Networks (WANs):
• Wide Area Network (WAN) is a computer network that covers a
broad area. The largest and most well-known example of a WAN is
the Internet. WANs are used to connect LANs and other types of
networks together, so that users and computers in one location can
communicate with users and computers in other locations
Fundamental Network Classifications
Metropolitan Area Network (MAN):
• A metropolitan area network (MAN) is a network that interconnects
users with computer resources in a geographic area or region larger
than that covered by even a large local area network (LAN) but
smaller than the area covered by a wide area network (WAN). The
area covers a city of 10 to 100KM
Intranet and Internet Specifications
• Intranet: An intranet is a private network that is contained within an
enterprise. It may consist of many interlinked local area networks and
also use leased lines in the wide area network.

• Internet: is a worldwide system of computer networks - a network of


networks in which users at any one computer can, if they have
permission, get information from any other computer (and
sometimes talk directly to users at other computers).
Client and Server computer role innetworking
• Server computer is a core component of the network, providing a link
to the resources necessary to perform any task.
• A server computer provides a link to the resources necessary to
perform any task.
• The link it provides could be to a resource existing on the server itself
or a resource on a client computer.
• Client computers normally request and receive information over the
network client. Client computers also depends primarily on the
central server for processing activities
Client/Server Networking
Peer-to peer network
• A peer-to-peer network is a network where the computers act as
both workstations and servers.
• great for small, simple, and inexpensive networks.
• In a strict peer-to-peer networking setup, every computer is an equal,
a peer in the network.
• Each machine can have resources that are shared with any other
machine.
• There is no assigned role for any particular device, and each of the
devices usually runs similar software. Any device can and will send
requests to any other.
Peer-to peer network
Exercises
• Define the following
1. Network
2. intranet
3. Internet

• Write short answers to the following:


1. What are the Advantages of networking?
2. Clarify the difference between client and server
3. Explain the peer-to-peer network?
Chapter 7

Algorithms
What is Algorithm? Algorithm Basics

• The word Algorithm means “a process or


set of rules to be followed in calculations
or other problem-solving operations”.

• Algorithm refers to a set of


rules/instructions that step-by-step
define how a work is to be executed
upon in order to get the expected
results.
It can be understood by taking an example of
cooking a new recipe.
To cook a new recipe, one reads the instructions and
steps and execute them one by one, in the given
sequence. Algorithm in
The result thus obtained is the new dish cooked General Life
perfectly.
Similarly, algorithms help to do a task in
programming to get the expected output.
Pseudocode:

Pseudocode is a simple way of writing


programming code in English. Pseudocode is not
actual programming language. It uses short
phrases to write code for programs before you
actually createit in a specific language.
Examples of Pseudocode:

Let'sreviewan example of pseudocode to


create a program to add 2 numbers together and then display the
result.

Start Program
Enter two numbers, A, B

Add the numbers together

Print Sum

End Program
Examples of Pseudocode:

Here is a pseudocode to compute the area of a rectangle:

Get the length, l, and width, w

Compute the area = l*w

Display the area


Characteristics of an Algorithm

• Clear and Unambiguous:


Algorithm should be clear and unambiguous. Each of its steps
should be clear in all aspects and must lead to only one meaning.
• Well-Defined Inputs:
If an algorithm says to take inputs, it should be well-defined
inputs.
• Well-Defined Outputs:
The algorithm must clearly define what output will be yielded and
it should be well-defined as well.
• Finite-ness:
The algorithm must be finite, i.e. it should not end up in an
infinite loops or similar.
Characteristics of an Algorithm

• Feasible:
The algorithm must be simple, generic and practical, such
that it can be executed upon will the available resources. It
must not contain some future technology.

• Language Independent:
The Algorithm designed must be language-independent, i.e.
it must be just plain instructions that can be implemented in
any language, and yet the output will be same, as expected.
Advantages of Algorithms

 It helps to understand the problem.


 Algorithm is a step-wise representation of a solution to a
given problem.
 In Algorithm the problem is broken down into smaller pieces
or steps hence, it is easier for the programmer to convert it
into an actual program.
How to Design an Algorithm?

In order to write an algorithm, following steps are needed as a pre-


requisite:

1. The problem that is to be solved by this algorithm.


2. The constraints of the problem that must be considered while solving the
problem.
3. The input to be taken to solve the problem.
4. The output to be expected when the problem the is solved.
5. The solution to this problem, in the given constraints.
Add 3 numbers Example

Step 1: Fulfilling the pre-requisites

• The problem that is to be solved by this algorithm: Add 3 numbers and


print their sum.
• The constraints of the problem that must be considered while solving the
problem: The numbers must contain only digits and no other characters.
• The input to be taken to solve the problem: The three numbers to be
added.
• The output to be expected when the problem the is solved: The sum of
the three numbers taken as the input.
• The solution to this problem, in the given constraints: The solution
consists of adding the 3 numbers. It can be done with the help of ‘+’
operator, or bit-wise, or any other method.
Continue….

Step 2: Designing the algorithm


Now let’s design the algorithm with the help of above pre-requisites:
Algorithm to add 3 numbers and print their sum:
• START
• Declare 3 integer variables num1, num2 and num3.
• Take the three numbers, to be added, as inputs in variables num1, num2, and num3
respectively.
• Declare an integer variable sum to store the resultant sum of the 3 numbers.
• Add the 3 numbers and store the result in the variable sum.
• Print the value of variable sum
• END
Continue….

Step 3: Testing the


algorithm by
implementing it.
Continue…
Questions

1. Define an algorithm.

2. What is pseudocode? Give an example

3. List the characteristics of an algorithm.

4. What are the advantages & disadvantages of an algorithm?

5. Design an algorithm to add 2 numbers and print their sum

6. Design an algorithm to multiply 3 numbers and print the result

7. Design an algorithm to calculate rectangle area / circle area etc.


Chapter 8

High Level Programing Languages


Definitions

 Computer program: A computer program is a set of instructions written in a


programming language to control the activities of a computer system.
 Instruction: Command to be executed by computer
 Computer programming: This is the process of writing a program using a
programming language.
 Programming language: It is an artificial language used by programmers to write
programs e.g. FOTRAN, COBOL, BASIC. ADA, C, C++, C#, Java, Python, Perl etc.
 Programmers: Persons who write programs using programming language
Types of programming languages

There are hundreds of programming languages that are classified into


two types, they are:

 High Level Language (HLL): HLL is a problem orientated programming language,


where the source programs (source code) are written in human readable
languages like English using an editor (Application or IDE)

 Low Level Language (LLL): LLL is the language that address the computer
machine. Machine dependent, bulky, prone to error, very tedious language.
Examples include: machine and assembly languages

write programs that relate to the specific architecture and hardware of a particular type of computer.
High Level Languages Categories - Execution model
There are two categories of programming languages execution model, they are: Interpreted and
compiled programming languages. An interpreted language use an interpreter and compiled
one use a compiler.
 An interpreter: Is a special program that translates and executes each source
statement at run-time, before translating and executing the next statement.
 Compiler:
High Level Languages Syntax, semantic, Data types and Variables

Syntax and Semantics


High Level Languages Syntax, semantic, Data types and Variables
High Level Languages Syntax, semantic, Data types and Variables
C++data types
Name Data Type Size

char Character 1 Byte

int Integer 2 Bytes

short int Short Integer 2 Bytes

long int Long Integer 4 Bytes

float Floating Point 4 Bytes

double Double Floating Point 8 Bytes

long double Long Double Floating Point 10 Bytes


C++Program Flow Control
Program flow control is used to alter the sequence in which the
program statements are executed. In C++ there are two flow
control statements, they are:

 Selection Statements: Includes if and the switch statements


 Iteration Statements: Includes do, do-while and for statements
High Level Languages Syntax, semantic, Data types and Variables
Exercise
A) Define the following
1. Computer program
2. Instruction
3. Computer programming
4. Programming language
5. Compiler
6. Syntax
7. Semantics
8. Variable

B) Encircle the correct option from the following


The rules that must be followed when writing a program are called …………………
a) syntax
b) key words
c) operators
ISE Computing Essentials 2023, Timothy J. O'Leary, Linda I. O'Leary and Daniel
O'Leary, 29th Edition, ISBN-13: 978-1265263218

Invitation to Computer Science, G. Michael Schneider 8th Edition, ISBN-13: 978-


Required Textbooks 1337561914
Latest Books are available in College Library.
Invitation to Computer Science, G. Michael Schneider & Judith Gersting, 6th
Edition, ISBN-13: 9781133190820.

ISE Computing Essentials 2023, Timothy J. O'Leary, Linda I. O'Leary and Daniel
O'Leary, 29th Edition, ISBN-13: 978-1265263218
Essential References
Materials Introduction to Computers 8th edition (Shelly Cashman Series) ISBN-13: 978-
1439081310

Electronic Materials https://www.slideshare.net/janfisher/chapter1-introduction-to-computers

Other Learning Materials Blackboard

You might also like