CHAPTER 1 INTRODUCTION
TO COMPUTER AND
PROGRAMMING
By: Ajaysinh Rathod
Topics to be covered
Introduction
Basic block diagram and functions of
various components of computer
Concepts of Hardware and software
Types of software
Compiler and interpreter
Concepts of Machine level
Assembly level and high level programming
Flowcharts and Algorithms
What is Computer?
The word computer comes from the word
“compute”, which means, “to calculate”.
A computer is an electronic device that
can perform arithmetic operations at
high speed and it can process data,
pictures, sound and graphics.
It can solve highly complicated problems
quickly and accurately.
It based on Input-Process-Output model
Fig 1:Simple workflow of computer
Advantages of Computer
Speed
It can calculate millions of expression within a fraction of second.
Storage
It can store large amount of data using various storage devices.
Accuracy
It can perform the computations at very high speed without any
mistake.
Reliability
The information stored in computer is available after years in same
form. It works 24 hours without any problem as it does not feel
tiredness.
Automation
Once the task is created in computer, it can be repeatedly
performed again by a single click whenever we want.
Multitasking
It can perform more than one tasks/operations simultaneously.
Disadvantages of Computer
Lake of intelligence
It can not think while doing work.
It does not have natural intelligence.
It can not think about properness,
correctness or effect of work it is doing.
Unable to correct mistake
It can not correct mistake by itself.
So if we provide wrong or incorrect data
then it produces wrong result or perform
wrong calculations.
Block Diagram of Computer
CENTRAL
PROCESSING UNIT
CONTROL
INPUT UNIT
OUTPUT
SECTION ARITHMATIC
SECTION
(Mouse, AND LOGICAL
(Monitor, Printer
Keyboard UNIT etc…)
etc…)
PRIMARY
MEMORY
(RAM, ROM etc…)
SECONDARY
MEMORY
(Hard disk, Pen drive
etc…)
Block diagram of computer (Input
Section)
The devices used to enter data in to
computer system are called input
devices.
It converts human understandable input
to computer controllable data.
CPU accepts information from user
through input devices.
Examples: Mouse, Keyboard, Touch
screen, Joystick etc…
Block diagram of computer (Input
Section)
Output Section
The devices used to send the
information to the outside world from the
computer is called output devices.
It converts data stored in 1s and 0s in
computer to human understandable
information.
Examples: Monitor, Printer, Plotter,
Speakers etc…
Output Section
Central Processing Unit (CPU)
It contains electronics circuit that processes the data based
on instructions.
It also controls the flow of data in the system.
It is also known as brain of the computer.
CPU consists of,
Arithmetic Logic Unit (ALU)
It performs all arithmetic calculations such as add, subtract, multiply,
compare, etc. and takes logical decision.
It takes data from memory unit and returns data to memory unit,
generally primary memory (RAM).
Control Unit (CU)
It controls all other units in the computer system. It manages all
operations such as reads instruction and data from memory.
Primary Memory
It is also known as main memory.
The processor or the CPU directly stores and retrieves information
Central Processing Unit (CPU)
Secondary Memory
Secondary memory is also called
Auxiliary memory or External memory.
It is Used to store data permanently.
It can be modified easily.
It can store large data compared to
primary memory. Now days, it is
available in Terabytes.
Examples: Hard disk, Floppy disk, CD,
DVD, Pen drive, etc…
Secondary Memory
What is Hardware?
Hardware refers to the physical parts of
a computer.
The term hardware also refers to
mechanical device that makes up
computer.
User can see and touch the hardware
components.
Examples of hardware are CPU,
keyboard, mouse, hard disk, etc…
What is Hardware?
What is Software?
A set of instruction in a logical order to
perform a meaningful task is called program
and a set of program is called software.
It tell the hardware how to perform a task.
Types of software
System software
It is designed to operate the computer hardware efficiently.
Provides and maintains a platform for running application
software.
Examples: Windows, Linux, Unix etc.
Application software
It is designed to help the user to perform general task such
as word processing, web browser etc.
Examples: Microsoft Word, Excel, PowerPoint etc.
What is Software?
Categories of System Software
Operating system
It controls hardware as well as interacts with users, and
provides different services to user.
It is a bridge between computer hardware and user.
Examples: Windows XP, Linux, UNIX, etc…
System support software
It makes working of hardware more efficiently.
For example drivers of the I/O devices or routine for
socket programming, etc…
System development software
It provides programming development environment to
programmers.
Example: Editor, pre-processor, compiler, interpreter,
loader, etc…
Categories of Application
Software
General purpose software
It is used widely by many people for some
common task, like word processing, web
browser, excel, etc…
It is designed on vast concept so many people
can use it.
Special purpose software
It is used by limited people for some specific
task like accounting software, tax calculation
software, ticket booking software, banking
software etc…
It is designed as per user’s special requirement.
Compiler, Interpreter and
Assembler
Compiler translates program of higher
level language to machine language. It
converts whole program at a time.
Interpreter translates program of higher
level language to machine language. It
converts program line by line.
Assembler translates program of
assembly language to machine
language.
Translation from HLL to ML
Types of Computer Languages
Types of Computer Languages
Source:
Types of Computer Languages
Source:
Types of Computer Languages
Machine level language OR Low level language
It is language of 0’s and 1’s.
Computer directly understand this language.
Ex: Binary Language
Assembly language
Assembly language is an example of middle-level language.
It uses short descriptive words (MNEMONIC) to represent each of the machine
language instructions.
It requires a translator knows as assembler to convert assembly language into
machine language so that it can be understood by the computer.
Examples: 8085 Instruction set
Higher level language
High-level language is a computer language which can be understood by the
users.
It is a machine independent language.
We can write programs in English like manner and therefore easier to learn and
use.
We use Compiler or interpreter to convert high-level language to low-level
language.
Examples: C, C++, JAVA etc…
ALGORITHMS AND FLOWCHARTS
A typical programming task can be
divided into two phases:
Problem solving phase
produce an ordered sequence of steps that
describe solution of problem
this sequence of steps is called an
algorithm
Implementation phase
implement the program in some
programming language
Steps in Problem Solving
First produce a general algorithm (one
can use pseudocode)
Refine the algorithm successively to get
step by step detailed algorithm that is
very close to a computer language.
Pseudocode is an artificial and informal
language that helps programmers
develop algorithms. Pseudocode is very
similar to everyday English.
Introduction to Algorithms
Algorithms for making things will often
be divided into sections;
the parts/components/ingredients (inputs)
required to accomplish the task
– actions/steps/methods (processing) to
produce the required outcome (output).
For example to build a model car, the
parts (inputs) are needed plus
instructions on how to assemble the car
(processing) and the result is the car
(output).
Pseudocode & Algorithm
Example 1: Write an algorithm to
determine a student’s final grade and
indicate whether it is passing or failing.
The final grade is calculated as the
average of four marks.
Pseudocode & Algorithm
Pseudocode:
Input a set of 4 marks
Calculate their average by summing and
dividing by 4
if average is below 50
Print “FAIL”
else
Print “PASS”
Pseudocode & Algorithm
Detailed Algorithm
Step 1: Input M1,M2,M3,M4
Step 2: GRADE (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS” endif
Stop
Flowchart
A schematic representation of a sequence of
operations, as in a manufacturing process or
computer program.
A graphical representation of the sequence of
operations in an information system or program.
Information system flowcharts show how data
flows from source documents through the
computer to final distribution to users.
Program flowcharts show the sequence of
instructions in a single program or subroutine.
Different symbols are used to draw each type of
flowchart.
Flowchart
A Flowchart
shows logic of an algorithm
emphasizes individual steps and their
interconnections
e.g. control flow from one action to the next
Symbols used in Flowchart
Start / Stop Input / Output
Process Decision Making
Subroutine Arrows
Number is positive or negative
Start
Read no
True False
Is no >= 0
Print no is Print no is
Positive Negative
Stop
Number is positive or negative
Step 1: Read no.
Step 2: If no is greater than
equal zero, go to
step 4.
Step 3: Print no is a negative
number, go to step 5.
Step 4: Print no is a positive
number.
Step 5: Stop.
Number is positive or negative
Step 1: Read no.
Step 2: If no is greater than
equal zero, go to
step 4.
Step 3: Print no is a negative
number, go to step 5.
Step 4: Print no is a positive
number.
Step 5: Stop.
Number is odd or even
Step 1: Read no.
Star
t Step 2: If no mod 2 = 0, go to
step 4.
Step 3: Print no is a odd, go to
Read step 5.
no
Step 4: Print no is a even.
Step 5: Stop.
T Is no % False
r 2=0
u
e
Print Print
no is no is
Even Odd
Stop
Largest number from 2 numbers
Step 1: Read a, b.
Start Step 2: If a>b, go to step 4.
Step 3: Print b is largest number, go
to step 5.
Read a, b Step 4: Print a is largest number.
Step 5: Stop.
True False
Is a>b
Print a is Print b is
largest largest
Stop
Largest number from 3 numbers
Start
Read a, b, c
True False
Is a>b
True False True
Is a>c Is b>c
False
Print a is Print c is Print b is Print c is
largest largest largest largest
Stop
Largest number from 3 numbers
Step 1: Read a, b, c.
Step 2: If a>b, go to step 5.
Step 3: If b>c, go to step 8.
Step 4: Print c is largest number, go to step 9.
Step 5: If a>c, go to step 7.
Step 6: Print c is largest number, go to step 9.
Step 7: Print a is largest number, go to step 9.
Step 8: Print b is largest number.
Step 9: Stop.
Print 1 to 10
Start
Step 1: Initialize a to 1.
Step 2: Print a.
Step 3: Repeat step 2
a=1
until a<=10.
Step 3.1: a=a+1.
a=a+1 Print a Step 4: Stop.
True False
Is a<=10
Stop
Algorithm Vs Flowchart
Flowchart Algorithm
Flowchart is a pictorial or Algorithm is a finite sequence
graphical representation of a of well defined steps for
program. solving a problem.
It is drawn using various It is written in the natural
symbols. language like English.
Easy to show branching and Difficult to show branching
looping. and looping.
Easy to understand. Difficult to understand.
Flowchart for big problem is Algorithm can be written for
impractical. any problem.
Any Question????
Thank You!!