PPS unit-1
PPS unit-1
Reference books:
1. Programming in ANSI C by Balagurusamy
2. C Programming: Test Your Skills, 1/e by Ashok Kamthane
3. Programming With Ansi And Turbo C book : Ashok Kamthane ...
4. Programming in C Ansi standard, by Yashwant Kanetkar
UNIT-1
Introduction to Computer and Programming
❑ 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
❖ Various types of Computer Languages
❖ Flowcharts and Algorithm
❖ Difference between Flowchart and Algorithm
Introduction
❑ What is Computer ?
✓ A Computer is a machine that accepts data as input, processes that data using
programs, and outputs the processed data as information. Many computers can
store and retrieve information using hard drives. Computers can be connected
together to form networks, allowing connected computers to communicate
with each other.
Computer History
✓ English Mathematician, Philosopher and
inventor
✓ 1791-1871
✓ Taught math at Cambridge University
✓ Invented a viable mechanical computer
equivalent to modern digital computer
Charles Babbage
BASIC BLOCK DIAGRAM OF COMPUTER
(IMP FOR EXAM)
❑ BASIC BLOCK DIAGRAM OF COMPUTER
❖ FUNCTIONS OF VARIOUS COMPONENT OF COMPUTER
2. Input section
3. Output section
4. Storage Devices
1. Central processing unit (CPU)
✓ Central processing unit is a main part of the computer system.
• It contains electronics circuitry 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.
3. 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..
4. Storage Devices (Secondary Memory)
✓ Secondary memory is also called Auxiliary memory or External memory.
✓ User can 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…
❑ ADVANTAGES AND LIMITATIONS OF COMPUTER
❖ Advantages:
✓ Speed: It can calculate millions of expressions within a fraction of second. The micro second and nano second
units are used to measure the speed of computers.
✓ Storage: It can store data in large quantity using various storage devices. Millions of paper file’s data can be
stored in single small pen drive. Moreover, it reproduces data whenever we need and whatever format we
need. Now a days, Gigabytes and Terabytes are units of data storage devises.
✓ Accuracy: Computer performs the computations at very high speed without any mistakes. For
example, multiplication of two very large number takes more time for human and there are high probabilities
of mistakes. Computer does it in parts of the second with accuracy level we want. Very high level of accuracy
is must in financial transaction, medical surgery, nuclear plant, etc… which can be satisfied by computer only.
✓ Reliability: It is very reliable device. 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 one task is created in a computer, it can be repeatedly performed again by single click
whenever we want. For example, once the software for banking application is installed in a computer, it
computes the interest by sending one command.
❑ ADVANTAGES AND LIMITATIONS OF COMPUTER
❖ Limitations:
✓ Lack of intelligence: It cannot think while doing work. It does not have natural intelligence.
It cannot think about properness or effect of work it is doing. It can only execute the
instructions but it cannot think about the correctness of these instructions.
Types Of Software
ii. System support software: It makes working of hardware more efficiently. For example drivers of
the I/O devices or routine for socket programming, etc…
ii. 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
❑ Hardware
✓ Physical parts of computer is known as Hardware. User can see and touch the hardware
components.
.
❑ Difference between Software and Hardware
COMPILER AND INTERPRETER
❑ Compiler
Fig: Compiler
❑ Interpreter
Fig: Interpreter
❑ Difference Between compiler and interpreter
1 Compiler takes entire program as an input. Interpreter takes single instruction as an input.
2 Compiler does not allow program to run until it Interpreter runs the program from first line and
is completely error free stops execution only if it finds an error
4 Error is displayed after entire program is Error is displayed for every instruction interpreted.
checked.
❖ DISADVANTAGES:
1. Programs are long and difficult to write and understand for human.
2. Debugging is very difficult task.
3. It is not portable.
4. Programmer requires detailed knowledge of architecture of microprocessor.
2. ASSEMBLY LANGUAGE
✓ Every machine language instruction is assigned to English word MNEMONIC such that it should describe
function of instruction
✓ System cannot understand this language directly so we require translator that convert assembly language to
machine language. This translator is called assembler
✓ Example : 8086 Instruction Set
❖ ADVANTAGES:
1. Programs are easy to understand compared to machine level language.
2. Programs are smaller in size compared to machine level language.
3. Programs can be entered quickly using alphanumeric keyboard
❖ DISADVANTAGES:
1. It is not portable.
2. Programmer should know structure of assembly language of microprocessor.
3. It requires assembler as a translator
3. HIGHER LEVEL LANGUAGE
✓ We can write programs in English like manner and it is more convenient to use.
✓ Programmer can perform complex task by using high level languages with less efforts.
✓ It is similar to natural language and mathematical notation.
✓ Example: C, C++, Java, etc
❖ ADVANTAGES:
1. Easier to learn.
2. Requires less time to write.
3. Provides better documentation.
4. Easier to maintain.
5. It is portable.
❖ DISADVANTAGES:
1. It requires compiler or interpreter to convert higher level language to machine language.
2. Programmers need to learn structure of high level language.
3. It is bit slow compared to low level and medium level language.
FLOWCHARTS AND ALGORITHM
❑ FLOWCHARTS
✓ Flowchart is a pictorial or graphical representation of a process. Each step in the process is represented by a
different symbol and contains a short description of the process step. The flow chart symbols are linked
together with arrows showing the process flow direction. This pictorial representation can give step-by-step
solution of the given problem.
❖ ADVANTAGES:
1. Easy to draw.
2. Easy to understand logic.
3. Easy to identify mistakes by non computer person.
4. Easy to show branching and looping.
❖ DISADVANTAGES:
1. Time consuming.
2. Difficult to modify.
3. Very difficult to draw flowchart for big or complex problems.
❖ VARIOUS SYMBOL USED IN FLOWCHART
FLOW CHART SYMBOL MEANING EXPLANATION
This symbol denoting the beginning/start and
Start and end end of flow chart
This symbol is used to read input data and
Action / (input/output) output or display the information
This symbol is used to represent process. For
Step / Process example: Arithmetic operations, Data
movement etc..
Diamond symbol are generally used to check
Decision any condition or take decision for which there
are two answers: yes(true), no(false)
Flow lines are used to connect symbol used in
Flow lines / Arrow flow chart and indicate direction of flow
❖ ADVANTAGES:
1. Easy to write.
2. Human readable techniques to understand logic.
3. Algorithms for big problems can be written with less efforts.
❖ DISADVANTAGES:
1. Difficult to debug.
2. Difficult to show branching and looping.
3. Jumping (goto) makes it hard to trace some problems.
❖ EXAMPLE: ALGORITHM TO FIND WHETHER THE GIVEN NUMBER IS EVEN OR ODD
✓ Algorithm:
Step 1 : Start
Step 2 : Input no.
Step 3 : If no mod 2=0, goto 5.
Step 4 : Print given no is odd, goto 6.
Step 5 : Print given no is even.
Step 6 : Stop.
❑ DIFFERENCE BETWEEN FLOWCHART AND ALGORITHM
4 Easy to show branching and looping. Difficult to show branching and looping.
5 Flowchart for big problem is impractical Algorithm can be written for any problem
❖ EXAMPLE: ALGORITHM & FLOWCHART TO FIND THE SUM OF TWO NUMBERS
FLOW CHART
ALGORITHM:
Step-1 Start
Step-2 Input first numbers say A
Step-3 Input second number say B
Step-4 SUM = A + B
Step-5 Display SUM
Step-6 Stop
❖ EXAMPLE: ALGORITHM & FLOWCHART TO FIND THE SUM OF TWO NUMBERS
FLOW CHART
ALGORITHM:
Step-1 Start
Step-2 Input two numbers say A & B
Step-3 SUM = A + B
Step-4 Display SUM
Step-5 Stop
❖ EXAMPLE: ALGORITHM & FLOWCHART TO FIND SIMPLE INTEREST
P : Principle Amount
N : Time in Years FLOW CHART
R : % Annual Rate of Interest
SI : Simple Interest
ALGORITHM:
Step-1 Start
Step-2 Input value of P, N, R
Step-3 SI = (P x N x R)/100
Step-4 Display SI
Step-6 Stop
❖ EXAMPLE: ALGORITHM & FLOWCHART TO FIND THE LARGEST OF TWO NUMBERS
ALGORITHM:
FLOW CHART
Step-1 Start
Step-2 Input two numbers say NUM1,NUM2
Step-3 if NUM1 > NUM2 goto Step-5
Step-4 Print NUM2 is Largest goto Step-6
Step-5 Print NUM1 is Largest number
Step-6 Stop
❖ EXAMPLE: ALGORITHM & FLOWCHART TO FIND THE LARGEST OF TWO NUMBERS
ALGORITHM:
FLOW CHART
Step-1 Start
Step-2 Input two numbers say NUM1,NUM2
Step-3 if NUM1 > NUM2 goto Step-5
Step-4 Print NUM2 is Largest goto Step-6
Step-5 Print NUM1 is Largest number
Step-6 Stop
THANK YOU