Unit1 - Fundamental of Computer
Unit1 - Fundamental of Computer
Computer Programming
Computer with C
(CTBTCSE SI P4)
2
● Computer is an electronic device used for storing,
processing, and retrieving the information.
● Computer has mainly two components:
What is ● Hardware
Computer ? ● The hardware of the computers consists of physical parts
of the system which are visible as well as user can touch
History of and feel it.
Computer ● The parts of the hardware are circuit boards, chips, CPU,
wires, Hard disk, Key board, Mouse, Printers and so on.
● Software:
● A software of the computers is logical part of the
computers and not visible to the users.
3
CPU
ALU
Arithmetic Logic Unit
of Computer CU
Secondary
Memory
4
● Central Processing Unit is the brain of the computer.
● It is also known as a processor.
Central ● The main purpose of the CPU is to execute the programs
Processing and stored in the memory.
● It consists main three parts: ALU, Main memory, C.U
Unit (CPU) 1. ALU (Arithmetic Logical Unit)
2. MU (Memory Unit)
3. C.U (Control Unit)
5
ALU ● ALU (Arithmetic Logical Unit):
(Arithmetic ● It Performs Arithmetical Operations like addition,
subtraction, multiplication, division and also performs
Logical Unit) logical operations like AND, OR, NOT operations.
6
● C.U (Control Unit):
● It controls all activities of C.P.U and other connected
devices. Its main job is to fetch instructions from the main
C.U memory and execute it over C.P.U.
(Control Unit) ● It has main two parts:
● IR (Instruction Register): It contains instructions that are in
execution.
● PC (Program Counter): It contains the address of the next
instruction for execution.
7
● Main memory:
● It is also known as primary memory or internal memory.
● It is used to store instructions and other information in
Binary form (0 or 1).
● This memory is also known as semiconductor memory
MU because it is made by semiconductor material like silicon.
(Memory Unit) ● It is divided into various types:
● RAM (Random Access Memory)
● ROM (Read Only Memory)
● PROM ( Programmable Read Only Memory)
● EPROM (Erasable Programmable Read Only Memory)
● EEPROM (Electrically Erasable Programmable Read Only
Memory)
8
● Input section of a computer consists of the devices
which are used to enter the information into the
computer from outside world.
Input Section ● The devices used to enter the input the computer are
called input devices.
● Example: Keyboard, Mouse, touch screen etc...
9
● Output section of a computer consists of devices used to
Output send the information to the outside world.
Section ● The devices used for output are known as output devices.
● Example: Monitor, Printer, LCD, Speakers etc...
10
● It is also known as Auxiliary memory or external
memory.
Secondary ● This is permanent memory.
Storage ● User can stored data permanently on this memory.
Devices ● It can be modified.
● Example: hard disk, floppy disk, CD, DVD, pen drive,
etc...
11
Hardware Software
It is divided into three parts : microprocessor , It is divided into two categories: System Software
motherboard & Other peripherals. & Application Software.
For design, it requires special software (chip For design, it requires system software.
designing software)
Ex : keyboard, mouse, monitor, CPU, printer......... Ex : Microsoft Office, Paint, loader, linker,
Operating System......
12
● A software is a one type of program that contains sequence
Computer of instructions to perform certain functionality.
● There are two types of software :
Software
1. System software
2. Application software
13
● System software is designed to operate the computer
hardware.
● It also provide platform for running application software.
System
● Types of system software :
Software 1. Operating system
2. System support software
3. System development software
14
● Application software is designed to perform specific
user applications.
● There are two categories of application software :
● General-purpose software: Microsoft Office, Oracle
etc.
Application ● Specific-purpose software : tax calculation software,
Software payroll system, Banking software's, etc.
● The most important categories of software packages
are as follows:
● Database management software
● Graphics software
● Data communication software
15
● An operating system acts as an intermediary
between the user of a computer and computer
hardware. The purpose of an operating system is to
provide an environment in which a user can execute
Overview of programs conveniently and efficiently.
types of ● An operating system is software that manages
operating computer hardware.
systems
16
● Type of Operating System
● MS-DOS
● Windows
Overview of ● LINUX
types of ● Solaris
operating ● Symbian
systems ● Android
● iOS
● Many more…
17
Compiler Interpreter
It checks the whole program at a time and It checks the program line by line and stops
then display the list of errors. checking whenever error occurs.
It converts whole source code into object It converts source code into object code line
code. by line.
The execution process of program is faster. The execution process of program is faster.
18
● Programming language is the language which is used to
write the program.
● Programming languages are divided into two categories:
Programming 1. Low level language
Languages 2. High level language
● Low level language is divided into two types:
1. Machine language
2. Assembly language
19
Programming
Languages
20
● The Machine language is written using binary language
(0’s and 1’s).
Machine ● Computer can understand only low level language.
Language ● So computer need not to convert it, so low level
Programming languages are faster.
● Machine Level language is also known as Binary
Language and Low Level language.
21
● Advantages of Machine language programming:
1. The programs are stored in very less memory.
Machine 2. Once programs are entered into main memory
Language computer can directly execute it without using any
translator.
Programming 3. Suitable for low volume application.
4. It does not require any translator to run (like
assembler).
22
● Disadvantages of Machine language programming:
1. The programs are difficult to understand and debug.
2. It requires more time to write the program because it
Machine is written in bit form (0’s and 1’s)
Language 3. The programmer often makes errors, which are
difficult to find.
Programming 4. It is not suitable for large application.
5. The program cannot be described because it is
written in bits.
6. The programs are not portable.
23
● The Assembly language is written using set of
instructions (mnemonics).
Assembly ● Assembly language programming is also low level
Language language
● Computer requires assembler to translate assembly
language into machine language.
24
● Advantages of Assembly language:
Assembly 1. The program is easy to describe because of
instructions.
Language 2. The programs are very easy to understand or debug.
3. It requires less time to write the program.
25
● Disadvantages of Assembly language:
1. It requires assembler to translate assembly language
Assembly into machine language.
2. Programmer needs to learn the structure of assembly
Language language and syntax of every statement.
3. Assembly language programs are not portable
because it is dependable on machine.
26
● The Higher level languages are written using English
statements.
● Computer cannot understand high level language.
● So Computer have to convert high level language
High Level into low level language.
Language ● So high level languages are slower than low level
language.
● Higher level language is a potable language across
machines.
● For Example: C, C++, FORTRAN, COBOL, Java...etc.
27
● Advantages of High level language:
1. The high level language is easy to understand or
debug.
High Level 2. No need to learn computer architecture because it is
Language not depends on the computer.
3. It requires less time to write the program because it is
written using English statements.
4. The programs are portable.
28
● Disadvantages of High level language:
1. It requires compiler or interpreter to translate high
level language into machine level language.
High Level 2. It also requires loader to load the programs into main
memory.
Language 3. Programmer needs to learn the structure of high level
language and syntax of every statements.
4. Some high level languages are dependent on
operating system.
29
● The translator translates high level language into low
level language.
Translator ● There are three types of translator:
1. Assembler
2. Compiler
3. Interpreter
30
● Assembler:
● Assembler converts assembly language into machine
level language.
● Compiler:
● Compiler converts high level language into low level
Translator language.
● First Compiler accept high level program as input.
● After it checks the program for any errors.
● If there is no error in the program then compiler
convert High level program into low level language.
● If there is any errors then compiler display list of
errors.
31
● Interpreter:
● Interpreter converts high level language into low level
language.
● First Interpreter accept high level program as input.
● After it checks the first statement of the program for
Translator error, if there is not any error in the first statement
then interpreter convert the statement into low level
language.
● If there is any error then it displays that error.
● This process is repeated until all the statement in the
program is checked.
32
● Algorithms:
● An algorithm is set of sequential instructions to solve a
specific task.
● It is also called as step by step solution of the problem.
Algorithms ● Properties of the Algorithm:
and ● Finiteness: Total number of steps used in algorithm should
be finite.
Flowcharts ● Definiteness: Each step must be clear and easy to
understand.
● Effectiveness: Every step must be basic and essential.
● Input and output: The algorithm must accept the all
possible inputs and must generate at least one output.
33
● Algorithm Example:
● AIM: Write an algorithm to find area of circle.
Step1: INPUT R
Step2: COMPUTE A = 3.14 * R * R
Step3: PRINT A
Algorithms Step4: END
and
Flowcharts
34
● Algorithm Example:
● AIM: Write an algorithm to find minimum of two numbers.
Step1: INPUT N1, N2
Step2: IF N1 < N2
THEN GOTO Step3
Algorithms ELSE GOTO Step4
and Step3: PRINT N1 GOTO Step5
Flowcharts Step4: PRINT N2
Step5: END
35
● Algorithm Example:
● AIM: Write an algorithm to find minimum of three
numbers.
Step1: INPUT N1, N2, N3
Algorithms Step2: IF N1 < N2
THEN GOTO Step3
and ELSE GOTO Step4
Flowcharts Step3: IF N1 < N3
THEN PRINT N1 and GOTO Step5
ELSE PRINT N3 and GOTO Step5
Step4: IF N2 < N3
THEN PRINT N2 and GOTO Step5
ELSE PRINT N3 and GOTO Step5
Step5:END
36
● Algorithm Example:
● AIM: Write an algorithm to print first N numbers.
Step1: Input N
Step2: SET ITR = 1
Step3: Repeat Step4 and Step5 While
Algorithms ITR<=N
and Step4: PRINT ITR
Flowcharts Step5: ITR = ITR + 1
Step6: END
37
● Algorithm Example:
● AIM: Write an algorithm to find sum of first N numbers.
Step1: Input N
Step2: SET ITR = 1, SUM = 0
Algorithms Step3: Repeat Step 4 and 5 While ITR<=N
Step4: SET SUM = SUM + ITR
and Step5: SET ITR = ITR + 1
Flowcharts Step6: PRINT SUM
Step7: END
38
● Advantages of the Algorithm:
● Very easy to write.
Algorithms ● Easy to understand.
● Easy to detect any mistakes.
and
● Disadvantages of the Algorithm:
Flowcharts ● Time consuming.
● Difficult to show branching and looping.
● It is helpful for only small application.
39
● Flowcharts:
● A flowchart is a graphical representation of algorithm or
Algorithms program.
and ● It represents the sequence of operation to be performed to
solve given task.
Flowcharts ● Flowcharts are used in analyzing, designing, documenting
or managing a process or program in various fields
● Different symbols are used to represent an algorithm.
40
● Different symbols:
Start
● Start and End symbols
● Represented as ovals or rounded rectangles, usually
containing the word "Start" or "End".
Algorithms ● Arrows
● Showing what's called "flow of control" in computer
and science. An arrow coming from one symbol and ending
Flowcharts at another symbol represents that control passes to
the symbol the arrow points to.
● Action or Process Symbol ADD 1 TO X
● Represented as rectangles.
Examples: "Add 1 to X"; "replace identified part"; "save
changes" or similar.
41
● Different symbols:
● Input/Output READ X
● Represented as a parallelogram.
Algorithms Examples: Get X from the user; display X.
and ● Subroutines PROCESS FILE
42
● Different symbols: Yes No
A<B
● Decision Symbol
● Represented as a diamond showing where a decision is
Algorithms necessary, commonly a Yes/No question or True/False
test.
and ● The conditional symbol has two arrows coming out of
Flowcharts it, one corresponding to Yes or True, and one
corresponding to No or False.
● Connector Symbol A
● Indicates that the flow continues where a matching
symbol (containing the same letter) has been placed.
43
● Flowchart Example:
● Draw a flowchart of process to find area of circle.
Start
Algorithms READ R
and
Flowcharts A = 3.14 * R * R
PRINT A
End
44
● Flowchart Example:
● Draw a flowchart of process to find minimum of two
numbers.
Start
Algorithms READ A, B
and Yes No
Flowcharts A<B
PRINT A PRINT B
End
45
● Flowchart Example:
● Draw a flowchart of process to find minimum of
three numbers.
Start
Algorithms READ A, B, C
and Yes
A<B
No
End
46
● Flowchart Example:
● Draw a flowchart of process to find sum of first N
numbers.
Start
Algorithms READ N
and
Flowcharts ITR=1, SUM=0
No
ITR<=N
PRINT SUM
Yes
SUM=SUM+ITR
ITR=ITR+1
End
47
● Introduction,
● Basic block diagram and functions of various
components of computer,
● Concepts of Hardware and software,
Review ● Types of software,
● Compiler and interpreter,
● Concepts of Machine level, Assembly level and high
level programming,
● Flowcharts and Algorithms
48
Thank
You.
49