2. What is a Computer?
• One that computes
• A digital computer is an electronic programmable machine that can
process almost all kinds of data.
Here, the programmable feature makes this machine unique because it
can be used in different fields by using different programs for different
environments.
3. Block Diagram of Computer
Input device Memory Output device
CPU
ALU CU
Dotted lines communication of control signals
Solid lines transfer of data
Input Device
• The input devices are used
to input data to computer.
• It converts the input
information to the form
which is usable by the
computer.
• Whatever input is supplied
by the input device(s), first
goes to memory.
4. Block Diagram of Computer
Input device Memory Output device
CPU
ALU CU
Dotted lines communication of control signals
Solid lines transfer of data
Output Device
• Under the control of CU,
the data comes from input
device to memory, it is
processed in ALU and the
result is stored back in the
memory.
• The processed results are
converted to human
readable form and is
displayed in the output
device.
5. Block Diagram of Computer
Input device Memory Output device
CPU
ALU CU
Dotted lines communication of control signals
Solid lines transfer of data
CPU
Computer brain
• Arithmetic-LogicUnit(ALU)
>>performs arithmetic
operations and conducts
logical decisions.
• Control Unit (CU)
>> responsible for sending/
receiving control signals
from/to all components
6. Block Diagram of Computer
Input device Memory Output device
CPU
ALU CU
Dotted lines communication of control signals
Solid lines transfer of data
Memory
• Primary Memory
>>faster in speed, less in
size, costlier
>>ROM (permanent),
RAM (volatile).
• Secondary Memory
>>cheaper, slower,
permanent in nature.
>>hard disk, floppy, CD.
7. Generations of Computers
• The First Generation: 1945-1956 (TheVacuumTubeYears)
- ENIAC, (EDSAC—1949, John von Neumann)
• The Second Generation: 1956-1963 (The Era of theTransistor)
- One transistor replaced the equivalent of 40 vacuum tubes
• TheThird Generation: 1965-1970 (Integrated Circuits-Miniaturizing the
Computer)
• The Fourth Generation: 1971-Today (The Microprocessor)
8. Algorithm
• Complete step by step representation of the solution of the
problem, represented in English like language.
Pseudo
Code
• More formal representation than the algorithm
• Very close to actual programming language
Flow chart
• Uses many graphical symbols to represent the steps of the
solution of the problem.
Program
• A set of instructions
• Written in a particular sequence in a computer-related language
9. Desirable Program Characteristics
• Integrity – refers to the accuracy of the calculation
• Clarity – refers to the overall readability of the program
• Simplicity – refers to keep things as simple as possible
• Efficiency – concerned with execution speed and efficient memory
utilization
• Modularity – refers to break down the program into several modules
• Generality – makes the program features as general as possible
10. • 55 48 89 E5C7 45 FC
0A 00 00 00 B8 00 00
00 00 5D C3Machine
Language
• main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 10
mov eax, 0
pop rbp
ret
Assembly
Language
• int main(){
int a=10;
return 0;
}
C
11. Structured Programming
• A technique for organizing and coding computer programs in which a
hierarchy of modules is used, each having a single entry and a single
exit point, and in which control is passed downward through the
structure without unconditional branches to higher levels of the
structure.
• 3 main principles:
1. Program design
2. Modular programming
3. Structuring of control flow
Three types of control flows are used:
a. Sequence (steps one after the other)
b. Selection (choose one out of 2/many)
c. Iteration (repeat steps many times)
12. 1.Program Design
• Top Down Approach
The problem is divided into
smaller sub-problems and these
sub-problems are also divided into
even smaller sub-problems.
• Bottom Up Approach
The process starts with
identification of the smallest sub-
components of the total program.
A
B
D
E
C F
Top Down Approach
Bottom Up Approach