Professional Documents
Culture Documents
4
Grading System
Grading System:
Midterm Examination 20%
Final Examination 20%
Class standing 60%
Class Standing is composed of:
Quizzes 18%
Laboratory Activities 12%
Seatwork/ Assignment 6%
Course Project 24%
5
House Rules
1. Permit
2. Delayed Exam
3. Major Exams
4. Deadline
5. Cheating
6. Attendance
7. Uniform
6
Textbook:
Problem Solving with C++, 7th Edition
By: Walter Savitch
References:
C++ for Engineers and Scientist
By: Gary J. Bronson
SAMS Teach Yourself C++ in 24 Hours
By: Jesse Liberty
C++ How to Program
By: Deitel and Deitel
Moodle Account
http://adnuengineering.net
username = <school id number>
password = AdnuEngg123!
0.5” 0.5”
1.0”
0.5”
Bonus Activity
Bonus Quiz
Assignment
1. Read and study the basic computer concepts, hardware and
software.
2. Identify and define the basic operation/fundamental function of a
computer system.
3. Describe hardware and software.
4. Identify and define the six logical units or sections of a
computer system.
5. Identify and define the general types of programming language.
12
College of Engineering
Ateneo De Naga University
Welcome to
Computer Programming
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
ADD X Y Z
◦ ADD might translate to 0110, the X might
translate to 1001, the Y to 1010, and the Z to
1011.
◦ 0110 1001 1010 1011
High-Level Programming Languages
4. Link Disk
Loader puts program
in memory.
..
5. Load ..
..
Primary
6. Execute CPU
Memory
CPU takes each
instruction and
executes it, possibly
.. storing new data
..
.. values as the program
executes.
Assignment No. 2
1. Identify the basic data units.
2. Identify the number systems and its different bases.
3. Show your complete solution.
Part 1I
II. Number System and Data
Representation
- Introduction to Number Systems
- Number System Conversion
- Data Representation
Objectives
Identify the number system and its different bases
Compute for different number base conversions
Describe the importance of number systems in relation
to computers and its applications
Discuss the different data representation.
INTRODUCTION
2.53
Positional Number Systems
The traditional number
system is called a
positional number system. 6354 6 *1000 3 *100 5 *10 4
A number is represented
as a string of digits. p 1
Each digit position has a D di 10 i
weight assoc. with it.
i 0
Number’s value = a
weighted sum of the digits
Radix/Base
300010 = 3 * 10 3 Exponent
Number of bits ^ 2
Taking an example using 8 bits
256 individual combinations we can make
• 128 64 32 16 8 4 2 1
• Lowest number we can represent
0 0 0 0 0 0 0 0
• Highest number we can represent
1 1 1 1 1 1 1 1
• We simply add up the numbers with a 1
• 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
We want to represent the number 83 in binary
(there’s a couple of ways of working it out)
• 128 64 32 16 8 4 2 1
0 (coz 128 don’t fit!)
1 (64 fits, leaves 19)
0
1 (leaves 3)
0 0
Gives us 1 (1 left)
1
0 1 0 1 0 0 1 1
Terminology
Bytes
A byte is a unit that represents with 8 bits 1 character or
number, 1 byte = 8 bits
E.g. “00000000”, “00000010”, etc.
1 bit can be represented in 2 ways, i.e. combination of 8 bit
patterns into 1 byte enables the representation of 28 = 256
types of information
Using a 1-byte word, 256 different characters can be
represented – sufficient for most Western character sets
Two bytes are connected to obtain 16 bits, 216 = 65,536
A 2-byte word
(or
Table)
(or Row)
(or Column)
Numeric Systems
Also known as Base Systems or Radix
Systems
Available digits:
Decimal system (base 10)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary system (base 2)
0, 1
Octal system (base 8)
0, 1, 2, 3, 4, 5, 6, 7
Hexadecimal (base 16)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
where A=10,B=11,C=12,D=13,E=14,F=15
Decimal Number
system
1
10 4 103 10 2 101 100 10 10 2 10 3 10 4 105
Decimal Number
System
• The decimal number system is a positional
number system.
• Example:
5 6 2 1 1 X 100 = 1
103 102 101 100 2 X 101 = 20
6 X 102 = 600
5 X 103 = 5000
Binary Number
System
• The binary number system is also a positional
numbering system.
24 23 22 21 20 2 1 2 2 2 3 2 4 2 5
Octal Number
System
12510 = 11111012
Decimal to Binary
Decimal to Binary (Fraction)
Decimal fraction is multiplied by 2
◦ Resulting integer portion is extracted (always be “0” or “1”)
◦ Resulting fraction portion is multiplied by 2
◦ Operation is repeated until the fraction portion becomes 0
When decimal fractions are converted into binary
fractions, most of the times, the conversion is not
finished, since no matter how many times the fraction
portion is multiplied by 2, it will not become 0. Most
decimal fractions become infinite binary fractions.
Decimal to Binary (Fraction)
Find the binary equivalent of (0.75)10.
Number to be recorded
0.75 × 2 = 1.50 1
0.50 × 2 = 1.00 1
Thus (0.75)10= (0.11)2.
Find the binary equivalent of (0.9)10.
Number (to be recorded)
0.9 × 2 = 1.8 1
0.8 × 2 = 1.6 1
0.6 × 2 = 1.2 1
0.2 × 2 = 0.4 0
0.4 × 2 = 0.8 0
0.8 × 2 = 1.6 1
0.6 × 2 = 1.2 1
0.2 × 2 = 0.4 0
0.4 × 2 = 0.8 0
0.8 × 2 = 1.6 1
0.6 × 2 = 1.2 1
0.2 × 2 = 0.4 0
0.4 × 2 = 0.8 0
0.8 × 2 = 1.6 1
0.6 × 2 = 1.2 1
0.2 × 2 = 0.4 0
Thus (0.9)10 = (0.111001100110011001)2.
0.4 × 2 = 0.8 0
0.8 × 2 = 1.6 1
Decimal to binary .14579
x 2
3.14579 0.29158
x 2
0.58316
x 2
1.16632
x 2
0.33264
x 2
0.66528
x 2
1.33056
11.001001...
etc.
Binary to Decimal (integer)
◦ Multiply each bit by 2n, where n is the
“weight” of the bit
◦ The weight is the position of the bit,
starting from 0 on the right
◦ Add the results
Example- Convert (101101)2 into decimal number.
Binary to Decimal (integer)
Bit “0”
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
Example- Convert (101101.11)2 into decimal number.
Binary to Decimal (fractions)
10 1011 1011
10101110112 = 2BB16
Binary to Hexadecimal (Fraction)
Binary to Hexadecimal (Fraction)
Binary to Hexadecimal (Fraction)
101011.10112 = ?16
10 1011 1011
10101110112 = 2B.B16
Hexadecimal to Binary
Convert each hexadecimal digit to its 4-bit binary
equivalent.
Combine all the binary numbers.
Hexadecimal to Binary (Integer)
1 digit of the hexadecimal number is
represented with a 4-digit binary number
Hexadecimal to Binary (Fraction)
Same technique as per integer
Hexadecimal to Binary (Fraction)
Octal to Binary
Convert each octal digit to a 3-bit equivalent
binary representation.
Combine the 3-bit section by removing the
spaces to get the binary number.
7 0 5
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Octal to Decimal (fraction)
Hexadecimal to Decimal
◦ Multiply each bit by 16n, where n is the “weight” of
the bit
◦ The weight is the position of the bit, starting from
0 on the right
◦ Add the results
Hexadecimal to Decimal
Use hexadecimal to
binary conversion
Use hexadecimal to
binary conversion
Use hexadecimal to
binary conversion
Worksheet 2
UNICODE
What about the CODES that ASCII cannot
represent? The Japanese for example
UNICODE is a 16 bit code which is used to
represent a lot more characters
Memory Required
Total Pixels
(2 * 80) * (2 * 80) = 25, 600
Each pixel could be one of 256 different
colours
256 requires 8 bits
25,600 * 8 = 204, 800 bits
204, 800 = 25,600 bytes or 25 kilobytes