10/12/2023
Dr. Dileep Kumar Singh
Head, JLU-SOET
[email protected] Problem Solving and Program
Design using C
Problem Solving and Program Design using C
B Tech/ B Tech (Hons.) CSE – 1st Sem.
Computer Fundamentals
PSPC
Digital Computer System
• A digital computer is considered to be a calculating
device that can perform arithmetic operations at
enormous speed.
• It is defined as a device that operates upon
information/data.
• To be able to process data the computer is made of
various functional units to perform its specified task.
PSPC
Dr. Dileep Kumar Singh 1
10/12/2023
Block Diagram of Digital Computer System
• The Computer receive input, process it and delivers
output
• To perform these tasks it has different units and each
unit is responsible for a specific task
PSPC
Input Unit
• Computers need to receive data and instruction in
order to solve any problem
• Input units used to transferring the data from users’
end to the computer
• Commonly used input devices are keyboard, mouse,
touch pad, touch screen, light pen, joystick, scanner,
barcode reader, digital camera etc.
PSPC
Output Unit
• It is used to transfer the processed information or the
results of a computation from the computer to the
user in a way required by the user.
• Commonly used output devices are monitor (Visual
Display Unit), Printers, projectors, speakers etc.
PSPC
Dr. Dileep Kumar Singh 2
10/12/2023
Central Processing Unit (CPU)
• The Control Unit (CU) and Arithmetic & Logic Unit
(ALU) together are called Central Processing Unit (CPU)
• The CPU is like brain performs the following functions:
– All calculations
– Takes all decisions
– Controls all units of the computer
PSPC
Arithmetic Logical Unit (ALU)
• All calculations are performed in the Arithmetic Logic Unit
(ALU) of the computer. It also does comparison and takes
decision.
• The ALU can perform basic operations such as addition,
subtraction, multiplication, division, etc and does logic
operations viz, >, <, =, ‘etc.
• Whenever calculations are required, the control unit
transfers the data from storage unit to ALU once the
computations are done, the results are transferred to the
storage unit by the control unit and then it is send to the
output unit for displaying results
PSPC
Control Unit (CU)
• It controls all other units in the computer.
• The control unit instructs the input unit, where to store
the data after receiving it from the user.
• It controls the flow of data and instructions from the
storage unit to ALU.
• It also controls the flow of results from the ALU to the
storage unit.
• The control unit is generally referred as the central
nervous system of the computer that control and
synchronizes its working
PSPC
Dr. Dileep Kumar Singh 3
10/12/2023
Storage Unit (Memory Device)
• Computer has mainly two types of memory:
– Main or primary memory:
• High speed memory used to control the data input or
output speed with the processor speed. Size of main
memory is small. Cost is high. Example of Main Memory
is RAM & ROM.
– Secondary Memory:
• Speed of this memory is slow. But we can use a vest
amount of secondary memory to story long size data.
Cost of Secondary memory is low.
– There is another type of super speed memory called
CASH Memory. Cash Memory is the Interface between
Main & Secondary \memory to maintain the speed gap
PSPC
10
Memory Types
• Classify the Memory on the basis of speed and space into
6 categories:
1. Register Memory: Used the Register for storage (very
less space).
Increasing
2. Main memory ( Primary) : Fast but less Space Main order of
3. Cash Memory: To maintain the Speed gap between Space &
Main and Secondary Memory Decreasing
4. Secondary Memory: Slow but large Space(Hard disk order of
Speed
Memory)
5. External Memory: External Device Memory like Pen-
drive, External HDD etc.
6. Network Memory: Used the Each System memory on
Network architecture.
PSPC
11
Software types
• Software is a set of instructions, programs which enable the computer to
perform specified task.
• In other words, software is nothing but binary code instructions which
control the hardware.
• There are two broad categories of software
– System software
• It is a set of programs that manage the resources/Components (Printers,
storage space, processing time, keyboard mouse etc.) of a computer
system.
• Example: All Operating System (MS-DOS, WINDOWS-XP, LINUX and so on.
– Application software
• It is a set of Programs that complete the particular task. Particular task may
be set of particular task or a single task.
• Example: Computer games, Microsoft office, paint application and so on.
PSPC
12
Dr. Dileep Kumar Singh 4
10/12/2023
Algorithm & Flow chart
• A typical programming task can be divided into two phases:
• Problem solving phase
– Problem solving phase produces an ordered sequence of steps that
describe the solution of problem, and this sequence of steps is called an
algorithm.
– Actually in this phase we follow the two steps:
• In First Step we write the General Algorithm, called pseudo code (Simply
English Description of each Step).
• In Second Step we Refine the each steps of pseudo code in the terms of
some command /instructions with the help of variables, data, function etc.
• Implementation phase
– In Implementation phase, we implement the Algorithm (as Designed in
Problem Solving phase) in some programming language.
PSPC
13
Algorithm & Flow chart
• Components of Algorithm: With the help of following parameters, we
can write any algorithm.
Algorithm Name (must be in capital letters)
Algorithm Parameters (if valid then pass in with name, this is optional)
Begin & End indication
Step No.
• General Structure of Algorithm:
ALGO_NAME (Parameters)
Begin,
Step 1: -------------------
……………………………….
End.
PSPC
14
Algorithm & Flow chart
• Example:
– Write an Algorithm to find out the sum of two integer Numbers.
– Pseudo code:
• Input two numbers
• Add them
• Print Addition
– Algorithm:
• SUM ( a,b)
• begin,
• Step1: Input a,b
• Step 2: Sum=a+b
• Step 3: Print Sum
• End.
PSPC
15
Dr. Dileep Kumar Singh 5
10/12/2023
Algorithm & Flow chart
• Flow Chart: A graphical representation of the sequence of
operations in an information system or program.
• Flow charts show the sequence of instructions in a single
program or subroutine.
• Different symbols are used to draw each type of flowchart.
A Flowchart
– shows logic of an algorithm
– emphasizes individual steps and their interconnections
– e.g. control flow from one action to the next
PSPC
16
Algorithm & Flow chart
• Symbols for Flow chart:
PSPC
17
Flow chart Example
Start
• Draw a flowchart
Input
that will take two num1
input numbers from Input
num2
user and show the
Num1
largest of the two Show
num2
No > Yes Show
num1
num2
numbers
Stop
PSPC
18
Dr. Dileep Kumar Singh 6
10/12/2023
Example
• Draw a flowchart for
finding the sum of
first fifty natural
numbers
PSPC
19
THANKS
PSPC
20
Dr. Dileep Kumar Singh 7