0% found this document useful (0 votes)
3 views57 pages

PPS - Unit 1 (1)

The document provides an introduction to computers and programming, covering essential topics such as computer components, hardware and software concepts, types of programming languages, and flowchart and algorithm creation. It discusses the advantages and limitations of computers, as well as the roles of input, output, and storage devices. Additionally, it explains the differences between system and application software, and the functions of compilers, interpreters, and assemblers.

Uploaded by

yashvibavadiya
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)
3 views57 pages

PPS - Unit 1 (1)

The document provides an introduction to computers and programming, covering essential topics such as computer components, hardware and software concepts, types of programming languages, and flowchart and algorithm creation. It discusses the advantages and limitations of computers, as well as the roles of input, output, and storage devices. Additionally, it explains the differences between system and application software, and the functions of compilers, interpreters, and assemblers.

Uploaded by

yashvibavadiya
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/ 57

Programming for Problem Solving

UNIT-1
Introduction To Computer And Programming

Prepared By:

Sheetal J. Nagar,

Government Engineering College, Rajkot


Syllabus Topics
1. Introduction,

2. Basic block diagram and functions of various components of


computer

3. Concepts of Hardware and software

4. Types of software, Compiler and interpreter

5. Concepts of

a. Machine level programming

b. Assembly level programming

c. High level programming

6. Flowcharts

7. Algorithms
1.
Introduction
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.
▪ Computer can not do anything without a Program.
▪ Charles Babbage is called the "Grand Father" of the computer. The First
mechanical computer designed by Charles Babbage was called Analytical
Engine. It uses read-only memory in the form of punch cards.
What is Computer?

▪ Computer is an advanced electronic device that takes raw data as input from
the user and processes these data under the control of set of instructions
(called program) and gives the result (output) and saves output for the future
use.

▪ It can process both numerical and non-numerical (arithmetic and logical)


calculations.
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.
Limitations of Computer
▪ Lake of intelligence

o Computers can’t Think and Decide.

o It does not have natural intelligence.

o It can not think about properness, correctness or effect of work it is doing.

o Totally dependent on the given programs and the user input

▪ Unable to correct mistake

o It can not correct mistake by itself.

o So if we provide wrong or incorrect data then it produces wrong result or

perform wrong calculations.


2.
Block diagram of computer
Block Diagram of Computer

Central Processing Unit

Control Unit

Input Devices Output Devices


Arithmetic And
(Mouse, Keyboard (Monitor, Printer
etc…)
Logical Unit etc…)

Memory Unit
(RAM, ROM Etc…)

Storage Devices
(Hard disk, Pen drive etc…)
Four components of Computer

1. Central processing unit (CPU)

a) ALU
b) CU
c) MU

2. Input Devices

3. Output Devices

4. Storage Devices
1) Central Processing Unit

▪ It is known as the “Brain” of the system.

▪ CPU is the main part of the computer that contains electronic circuitry

that actually process the data.

▪ 3 Components of the CPU


1) ALU

2) CU

3) Memory Unit
1) Central Processing Unit
1) ALU (Arithmetic and Logic Unit):
- It performs all arithmetic calculations and takes logical decision.
- It can perform add, subtract, multiply, compare, count, shift and other logical activities.
- It takes data from the memory unit and performs calculations and returns data.
- Calculations are performed very fast.

2) CU (Control Unit):
- Controls all the operations performed in computer.
- It reads instructions from the memory,
- It decodes the instructions and
- executes the instructions.
- It also coordinates the time and sequence of the instructions among various components.
1) Central Processing Unit
3) Memory Unit:
- CPU contains primary memory RAM and ROM.
- Its storage capacity is very small compared to secondary storage.
- It is very fast in an operation compared to secondary storage
- RAM ➔ Random Access Memory
Can be Read and Write
Volatile Memory (It cannot retain data without power)
It means data will be lost in case of power failure or system crash.
So It stores data on temporary basis.
- ROM ➔ Read Only Memory
We can’t write in it.
Non volatile memory (It can retain data without power)
ROM is an integrated circuit programmed with specific data when it is manufactured.
2) Input Devices
▪ The devices which are used to enter the data into the computer from the outside world.

▪ CPU accepts information from user from input devices.

▪ Examples of the input devices:

– Keyboard – Web Camara

– Mouse – Joystick

– Scanner – Touch screen

▪ Keyboard is used to enter data by pressing the keys on it.

▪ Mouse is a pointing device which points at the desired position on the screen, it gives

input by clicking its button.


3) Output Devices
▪ The devices which gives output to the user are known as output devices.

▪ These devices supply the result of the processing to the user.

▪ The output device translates the data from a machine coded form (in 1s and 0s) that

can be understood by the user.

▪ To display, Monitor is the basic output device.

▪ Examples of the output devices:


- Monitor

- Printer

- Plotter

- Speakers
4) Storage Devices

▪ The Secondary memory is also called Auxiliary memory.


▪ User can store data permanently.
▪ It can be modified easily.
▪ It is slower than the primary memory.
▪ It is cheaper than the primary memory.
▪ It can store large data compared to primary memory.
▪ It has large capacity in terms of GB and TB (Giga Bytes and Tera Bytes).
▪ It is Non Volatile Memory (It can retain data without power)
▪ Examples: Hard disk, Floppy disk, CD, DVD, Pen drive, etc…
3.
Concepts of Hardware and Software
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…


Software
▪ Program:
“A set of instruction in a logical order to perform a meaningful task is
called program”.
▪ Software:
“A set of instruction in a logical order to perform a meaningful task is
called program, and set of program is called software”.
▪ It tells the hardware how to perform a task.
▪ Types of software
▪ System software
▪ Application software
# Hardware Software
1 Hardware are electronic devices. Software are sets of executable instructions
Software tells the inter-connected hardware
A computer is primarily a machine built-up with
2 devices that what to do, how to do and when to
inter-connected hardware devices.
do.

We can see and touch hardware as they are We can see (if there is a user interface) and use
3
physical electronic devices. software but can’t actually touch them.

Hardware is required to not only process data Software gives the hardware necessary
4 but also to take input and send output and instructions to perform the tasks of input, output
store output. and processing

Hardware wears out over time as they are


5 Software doesn’t wear out over time
mechanical electronic devices.
Software is just opposite, they are upgradable,
Hardware are rarely upgradable, user need to almost all software vendor regularly provides
6 replace old hardware with new hardware for updates to their software to make it perform
additional performance or function. better, perform additional tasks and more bug
free.
4.
Types of Software
Types of software

1) 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.

2) 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.


Categories of system software
1) Operating system
▪ Operating system is system software which works as an interface between hardware an
user and provides interactive platform to user.

▪ 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…

2) System support software


▪ It makes working of hardware more efficiently.

▪ For example drivers of the I/O devices or Anti virus Software, etc…

3) System development software


Categories of Application software
1) 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.

2) 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

1) Compiler translates program of higher level language to machine


language. It converts whole program at a time.

2) Interpreter translates program of higher level language to machine


language. It converts program line by line.

3) Assembler translates program of assembly language to machine


language.
4) Linker
It binds (links) source code and library file to make executable Program.
Software

System Application
software software

System General purpose Special purpose


Operating System support
Development software software
system software
software

Ex. Ex. Ex. Ex. Ex.


- Windows - Drivers - compiler - Word processing - Banking software
- Linux - Anti virus Software - interpreter - Excel - Ticket booking software
- Unix - Linker - Power Point - Accounting software
- loader - web browser - Tax calculation software
- Editor

- preprocessor
5.
Types of Programming languages
Programming languages

Machine Level Assembly Level High Level


Programming Programming Programming
1) Machine Level Programming

1. Machine level programming is also known as Low level programming.

2. Computer directly understands this language.

3. It’s Programs are written in Binary.

4. It is a language of 0’s and 1’s (binary).

5. Every CPU has its own machine language.

6. As Binary code (Instruction Set) varies from machine to machine, Programs written in
Machine Language are not portable.

7. Program written in Binary code for one machine, will not work for other machine.
1) Machine Level Programming
Advantages
▪ It is very fast in execution
▪ It does not require any extra system or software to run the program.
▪ Translation is not required.
▪ Suitable for low volume applications.

Disadvantages
▪ Requires depth technical knowledge to debug program.
▪ Difficult to understand.
2) Assembly language

1. Uses MNEMONIC (English word like ADD, SUB, MUL, DIV etc.) instead of 0’s
and 1’s.

2. Such symbolic representation makes program easy to write and understand.

3. System cannot understand assembly language directly so we require


translator that convert assembly language to machine language. This
translator is called assembler.

4. Example : 8086 Instruction Set


2) Assembly language
Advantages
▪ Programs are easy to understand compared to machine level
language.
▪ Programs are smaller in size compared to machine level language.
▪ Programs can be entered quickly using alphanumeric keyboard.

Disadvantages
▪ It is not portable.
▪ Programmer should know structure of assembly language of
microprocessor.
▪ It requires assembler as a translator.
3) Higher level language

1. We can write programs in English like manner and it is more convenient to


use than Assembly Language.

2. Programmer can perform complex task by using high level languages with
less efforts.

3. It is similar to natural language and mathematical notation.


3) Higher level language
Advantages
▪ Easier to learn.
▪ Requires less time to write programs .
▪ Provides better documentation.
▪ Easier to maintain.
▪ It is portable.
Disadvantages
▪ It requires compiler or interpreter to convert higher level language to machine
language.
▪ Programmers need to learn structure of high level language.
▪ It is bit slow compared to low level and assembly level language.
6.
Flowchart
Flowchart
▪ Flowchart is a pictorial or graphical representation of a program.

▪ It is easy to understand logic and sequence of the problem using flowchart.

▪ Each step in the flowchart is represented by a different symbol and contains


a short description of the step.

▪ After drawing the flowchart, it becomes easy to write the program.

▪ As it represents the solution of the problem in the form of the picture, it is


more easier to understand the develop program using flowchart.

▪ The flow chart symbols are linked together with arrows showing the process
flow direction.
Purpose Symbol

Start/Stop

Input/Output
Flowchart
Symbols Process

Decision Making

Connectors

Arrows
Ex.1) Start
Flowchart to find Total
Input a, b, c
and Average of 3
numbers
Total = a + b + c

Average = Total / 3.0

Print Total, Average

Stop
Ex.2)
Flowchart to find Start
Simple Interest.
Input R, P, N

Interest = ( R * P * N ) / 100

Print Interest

Stop
Ex.3) Start

Flowchart to find
Input a
whether a number is
odd or even Yes No
If (a % 2 == 0 )

Print “Even” Print “Odd”

Stop
Start
Ex.4)
Flowchart to find Input a

whether a number is
Yes No
Positive, Negative or if (a>0)

Zero.
Yes No
if (a<0)
Print
“Positive”

Print Print
“Negative” “Zero”

Stop
Start
Ex.5)
Flowchart to find Input a, b

Maximum among 2
Yes No
numbers if (a>b)

Print “a is max” Print “b is max”

Stop
Ex.6) Start

Flowchart to find
Input a,b,c
Maximum among 3
numbers. Yes No
if (a>b)

Yes No Yes No
if (a>c) if (b>c)

Print Print Print Print


“a is max” “c is max” “b is max” “c is max”

Stop
7.
Algorithm
Algorithm
▪ “An algorithm is a step by step solution of any problem”.

▪ “An Algorithm is a finite sequence of well defined steps by steps

procedure for solving a problem in systematic manner which produces

effective output for specific input in given amount of time”.

▪ It is written in the natural languages like English.


Algorithm
Advantages
▪ Easy to write.
▪ Human readable techniques to understand logic.
▪ Algorithms for big problems can be written with moderate efforts.
Disadvantages
▪ Difficult to debug.
▪ Difficult to show branching and looping.
▪ Jumping (go to) makes it hard to trace some problems.
Ex.1)
Algorithm to find Total Step 1 : Start

and Average of 3 Step 2 : Input a, b, c


numbers Step 3 : Calculate Total = a + b + c

Step 4 : Average = Total / 3.0

Step 5 : Print Total, Average

Step 6 : Stop
Ex.2)
Step 1 : Start
Algorithm to find
Step 2 : Input P, R, N
Simple Interest.
Step 3 : Calculate Interest = ( R * P * N ) / 100

Step 4 : Print Interest

Step 5 : Stop
Ex.3)
Step 1 : Start
Algorithm to find
whether a number is Step 2 : Input a

odd or even Step 3 : Check if(a%2) == 0 then go to Step 4

else go to Step 5

Step 4 : Print “Number is Even” go to Step 6

Step 5 : Print “Number is Odd”

Step 6 : Stop
Step 1 : Start
Ex.4)
Step 2 : Input a
Algorithm to find
whether a number is Step 3 : Check if(a>0) then go to Step 4

Positive, Negative or else go to Step 5


Zero.
Step 4 : Print “Number is Positive” go to Step 8

Step 5 : Check if(a<0) then go to Step 6

else go to Step 7

Step 6 : Print “Number is Negative” go to Step 8

Step 7 : Print “Number is Zero”

Step 8 : Stop
Ex.5) Step 1 : Start
Algorithm to find
Step 2 : Input a,b
Maximum among 2
Step 3 : Check if(a>b) then go to Step 4
numbers
else go to Step 5

Step 4 : Print “a is Maximum” go to Step 6

Step 5 : Print “b is Maximum”

Step 6 : Stop
Ex.6) Step 1 Start
Flowchart and
Step 2 Input a
Algorithm to find
Maximum among 3 Step 3
Yes No
numbers. if (a>b)

Step 4 Step 7
Yes No Yes No
if (a>c) if (b>c)

Step 5 Step 6 Step 8 Step 9

Print Print Print Print


“a is max” “c is max” “b is max” “c is max”

Step 10 Stop
Ex.6) Step 1 : Start
Algorithm to find Step 2 : Input a,b,c

Maximum among 3 Step 3 : Check if(a>b) then go to Step 4


else go to Step 7
numbers.
Step 4 : Check if(a>c) then go to Step 5
else go to Step 6
Step 5 : Print “a is Maximum” go to Step 10
Step 6 : Print “c is Maximum” go to Step 10
Step 7 : Check if(b>c) then go to Step 8
else go to Step 9
Step 8 : Print “b is Maximum” go to Step 10
Step 9 : Print “c is Maximum”
Step 10 : Stop
Why C is called
Middle level language?
Why C is called middle level language?

▪ C is called middle-level language because it provides features of both

low level language and high-level language.

▪ A user can use c language to develop System level programs (for writing

operating system) as well as Application Programs (for generating menu

driven customer billing system ).


Why C is called middle level language?
▪ like Low Level Language:

✓ In C we can directly access system registers (Using inline assembly language


feature) .

✓ C Programming is used to access memory directly using pointer.

▪ like High Level Language:

✓ C supports higher degree of readability and machine independence.

✓ It is more User friendly as compare to Previous languages.

You might also like