Lecture 01 Introduction
Lecture 01 Introduction
Using
March-2025
Chapter I
Overview of Computer and Programming
2
Course Content
3
Course Objectives
5
Hardware
• CPU
• Main memory: RAM
• Input/output devices
• Secondary storage
6
CPU (Central Processing
Unit)
• CU (Control Unit):
– Fetches and decodes instructions
– Controls flow of information in and out of MM
– Controls operation of internal CPU components
• PC (program counter): points to next instruction to be
executed
7
CPU (Central Processing
Unit) (continued)
• IR (instruction register): holds instruction currently being
executed
• ALU (arithmetic logic unit): carries out all arithmetic and logical
operations
8
9
Fig: Hardware Components of a Computer
Main Memory
• Directly connected to the CPU
• All programs must be loaded into main memory before they
can be executed
• All data must be brought into main memory before it can be
manipulated
• When computer power is turned off, everything in main
memory is lost
10
11
Secondary Storage
• Secondary storage: device that stores information permanently
• Examples of secondary storage:
– Hard disks
– Flash drives
– Floppy disks
– Zip disks
– CD-ROMs
– Tapes
12
Input/Output Devices
• Input devices feed data and programs into computers; they
include:
– Keyboard
– Mouse
– Secondary storage
• Output devices display results; they include:
– Monitor
– Printer
– Secondary storage
13
Software
• Software: programs that do specific tasks
• System programs take control of the computer, such as an
operating system
• Application programs perform a specific task
– Word processors
– Spreadsheets
– Games
14
The Language of a
Computer
• Digital signals are sequences of 0s and 1s
• Machine language: language of a computer
• Binary digit (bit):
– The digit 0 or 1
• Binary code:
– A sequence of 0s and 1s
• Byte:
– A sequence of eight bits
15
16
Coding Schemes
• ASCII (American Standard Code for Information Interchange)
– 128 characters
– A is encoded as 1000001 (66th character)
– 3 is encoded as 0110011
17
Base-N Number System
• Base N
• N Digits: 0, 1, 2, 3, 4, 5, …, N-1
• Example: 1045N
• Positional Number System
• n 1 4 3 2 1 0
N L N N N NN
dn1 L d4 d3 d2 d1 d0
• Digit do is the least significant digit (LSD).
• Digit dn-1 is the most significant digit (MSD).
18
Decimal Number System
• Base 10
• Ten Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Example: 104510
• Positional Number System
n 1 4 3 2 1 0
10 L 10 10 10 10 10
dn1 L d4 d3 d 2 d1 d0
• Digit d0 is the least significant digit (LSD).
• Digit dn-1 is the most significant digit (MSD).
19
Binary Number System
• Base 2
• Two Digits: 0, 1
• Example: 10101102
• Positional Number System
n 1 4 3 2 1 0
2 L 2 2 2 22
bn1 L b4 b3 b2 b1 b0
• Binary Digits are called Bits
• Bit bo is the least significant bit (LSB).
• Bit bn-1 is the most significant bit (MSB).
20
Definitions
• nybble = 4 bits
• byte = 8 bits
• (short) word = 2 bytes = 16 bits
• (double) word = 4 bytes = 32 bits
• (long) word = 8 bytes = 64 bits
• 1K (kilo or “kibi”) = 1,024
• 1M (mega or “mebi”) = (1K)*(1K) = 1,048,576
• 1G (giga or “gibi”) = (1K)*(1M) = 1,073,741,824
21
Hexadecimal Number
System
• Base 16
• Sixteen Digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
• Example: EF5616
• Positional Number System
• n1 4 3 2 1 0
16 L 16 16 16 16 16
0000 0 0100 4 1000 8 1100 C
0001 1 0101 5 1001 9 1101 D
0010 2 0110 6 1010 A 1110 E
0011 3 0111 7 1011 B 1111 F
22
Binary Addition
23
Hex Addition
• 4-bit Addition
4 + 4 = 8
4 + 8 = C
8 + 7 = F
F + E = 1D Note “carry”
24
1’s Complements
• 1’s complement (or Ones’ Complement)
– To calculate the 1’s complement of a binary number just “flip”
each bit of the original binary number.
– E.g. 0 1 , 1 0
– 01010100100 10101011011
25
2’s Complements
• 2’s complement
– To calculate the 2’s complement just calculate the 1’s
complement, then add 1.
01010100100 10101011011 + 1=
10101011100
– Handy Trick: Leave all of the least significant 0’s and first
1 unchanged, and then “flip” the bits for all other digits.
• Eg: 01010100100 -> 10101011100
26
Coding Schemes
(continued)
• EBCDIC
– Used by IBM
– 256 characters
• Unicode
– 65536 characters
– Two bytes are needed to store a character
27
ALGORITHMS AND FLOWCHARTS
Implementation Phase
implement the program in some programming language
28
Steps in Problem Solving
First produce a general algorithm (one can use
pseudocode)
Refine the algorithm successively to get step by step
detailed algorithm that is very close to a computer
language.
30
Pseudocode & Algorithm
Pseudocode:
Input a set of 4 marks
31
Pseudocode & Algorithm
Detailed Algorithm
Step 1: Input M1,M2,M3,M4
Print “FAIL”
else
Print “PASS”
endif
32
The Flowchart
(Dictionary) A schematic representation of a sequence of
operations, as in a manufacturing process or computer
program.
34
Flowchart Symbols
Name Symbol Use in Flowchart
PRINT PRINT
“PASS” “FAIL”
STOP
36
What is a Programming
Language?
A programming language is a notational system
for describing computation in machine-readable and
human-readable form.
38
The Six Primary Reasons
Increased ability to express ideas
40
Programming Domains
Scientific Applications
Business Applications
Artificial Intelligence
Web Software
41
Numerically-Based Languages
42
FORTRAN
John Backus’s team at IBM developed FORTRAN (for
FORmula TRANslator) in 1955-1957.
While FORTRAN was designed for numerical
computation, it included control structures, conditions
and input/output.
John McCarthy of MIT developed LIST for the IBM 704 (which
eventually led to Scheme and Common LISP). LISP is a
recursion-oriented, list-processing language that facilitated
game-playing programs.
Yngve of MIT developed COMIT, a string-processing language,
which was followed by AT&T’s SNOBOL.
Prolog was developed by Colmerauer, Roussel and Kowalski
based on predicate calculus and mathematical logic. 45
Systems Languages
Assembly languages were used for a very long time operating
systems programming because of its power and efficiency.
CPL, BCPL, C and C++ were later developed for this purpose.
46
Web Software
Eclectic collection of languages:
Markup (e.g., HTML) – used for annotating a document in a
manner that can be distinguished from the text.
47
Language Evaluation Criteria
Readability – the ease with which programs can be read and
understood.
48
The Evolution of
Programming Languages
Early computers were programmed in machine language
49
Assembly Language
Assembly language instructions are mnemonic
50
Assembly Language
(continued)
Using assembly language instructions,
LOAD rate
MULT hour
STOR wages
51
High-Level Languages
High-level languages include Basic, FORTRAN, COBOL, Pascal,
C, C++, C#, and Java
Compiler: translates a program written in a high-level language
machine language
The equation wages = rate • hours can be written in
C++ as:
wages = rate * hours;
52
Programming Evolution
53
Calculate :
Machine Language
Assembly Language
C++
54
What is a program ?
A program is a sequence of instructions that specifies how
to perform a computation and written in a language the
computer understands.
The computation might be something mathematical, such
as solving a system of equations or finding the roots of a
polynomial.
But it can also be a symbolic computation, such as searching
and replacing text in a document or (strangely enough)
compiling a program.
55
Programming: a way of
Thinking
Combines features from mathematics, engineering, and natural
science.
Like Mathematicians: computer scientists use formal languages
to denote ideas (specifically computations).
Like Engineers: they design things, assembling components into
systems and evaluating tradeoffs among alternatives.
Like Scientists: they observe the behavior of complex systems,
form hypotheses, and test predictions.
The single most important skill for a computer scientist is problem
solving. Problem solving means the ability to formulate problems,
think creatively about solutions, and express a solution clearly and
accurately.
56
Compiler & Interpreter
57
Their Difference
58
Brief History of C++
C++, with its robust syntax and performance-centric approach,
stands as a pivotal cornerstone in the world of modern
programming.
60
Brief History of C++
61
Cont..
C++ is a general-purpose programming language that was
developed as an enhancement of the C language to include
object-oriented paradigm.
62
Cont…
2. One of the key features of C++ is its ability to support low-level,
system-level programming, making it suitable for developing
operating systems, device drivers, and other system software.
And used for developing desktop applications, video games,
and other complex applications.
65
Cont…
66
Cont…
67
Cont…
68
Cont…
69
Cont…
70
Cont…
71
Summary
72
Cont…
73
Cont…
74
Cont…
75
Cont…
76
Cont…
77
Cont…
78
Cont…
79
Artificial Intelligence
80
Cont…
81
Cont…
82
Cont…
83
Cont…
84