44

PROGRAM LOGIC AND FORMULATION

Embed Size (px)

Citation preview

Page 1: PROGRAM LOGIC AND FORMULATION
Page 2: PROGRAM LOGIC AND FORMULATION

GENERATIONS OF COMPUTER

ABACUS - Developed around 300 years

BC by the Mesopotamians and later

improved by Chinese.

An abacus consists of beads divided into

two parts which are movable on the rods of

the two parts.

Page 3: PROGRAM LOGIC AND FORMULATION

FIRST GENERATION COMPUTER (1940 - 1956)

Vacuum Tubes

ENIAC (Electronic numerical Integrated And

Computer).

Developed by Presper Eckert and John Mauchly ,

ENIAC was made up of 18,000 vacuum tubes and

occupied a 30 x 50 feet room.

Programming was done by plugging wires into a

patch panel.

KEY FEATURES :Big and Clumsy Computers

that used Vacuum Tubes.

Not very reliable as Electric

failure occurred regularly.

Large air Conditioners were

necessary because the

computers Generated lot of

heat.

Used stored program

concept.

Input and Output Devices :

Either No Input Devices

(Hardware programs) or Control

REMARKS :Very large space requirement.

High electricity consumption.

Generated lot of heat.

Slow operating speed.

Restricted computing

capacity.

Limited Programming

capabilities.

Memory Type : Magnetic Drums

Storage: Punched Cards and

paper Tapes.

Page 4: PROGRAM LOGIC AND FORMULATION
Page 5: PROGRAM LOGIC AND FORMULATION
Page 6: PROGRAM LOGIC AND FORMULATION

FIRST GENERATION COMPUTER (1940 - 1956)

Vacuum Tubes

Trajectory tables for weapons. (too late for war

effort).

Programmed manually by Switches.

18,000 vacuum tubes.

30 tons

15,000 square feet

140 kW power consumption

5,000 additions per second.

DISADVANTAGES:

1. They were to bulky.

2. They emitted large amounts of heat because they

used lots of vacuum tubes.

3. AIR conditioning was required.

4. They were Prone to frequent that’s why they were

unreliable.

5. They were not Portable.

Page 7: PROGRAM LOGIC AND FORMULATION

SECOND GENERATION COMPUTER(1956 - 1963)

Transistors

The creation of transistor sparked the production of

a wave of second generation computer. Transistor

was a small device used to transfer the electronic

signals across a resistor. Transistors had many

advantages compared to vacuum tubes. KEY FEATURES :Transistors replaced vacuum

tubes.

Smaller in size compared to

1st generation computers.

Generated lesser heat than

earlier computer.

Low electricity consumption.

More reliable and faster.

Input Devices and Output

Devices : Punched Cards.

REMARKS :Not General – purpose

computers – mostly suitable to

scientific and bulk data

processing tasks only; not for

business purposes.

The machines were costly

Frequent Maintenance

required. .

Page 8: PROGRAM LOGIC AND FORMULATION
Page 9: PROGRAM LOGIC AND FORMULATION
Page 10: PROGRAM LOGIC AND FORMULATION

THIRD GENERATION COMPUTER(1964 - 1971)

Integrated Circuits

The development of integrated circuits (IC) in 1961,

signaled the beginning of the third generation

computers and the integrated circuit technology,

which had reduced the size and cost of computers

enormously.

It is also known as Semiconductor.KEY FEATURES :Integrated Circuits

Computers Smaller , faster

and more reliable.

Lower power consumption

High level languages

developed

Input and Devices : Keyboards

and printers.

REMARKS :Proved to be highly reliable ,

relatively , inexpensive, and

faster.

Less human labour was

required at assembly stage.

Page 11: PROGRAM LOGIC AND FORMULATION
Page 12: PROGRAM LOGIC AND FORMULATION
Page 13: PROGRAM LOGIC AND FORMULATION

FOURTH GENERATION COMPUTER(1971 - Present)

Microprocessors

In 1971 Intel Created the first microprocessor and

the era of fourth generation computers started.

During the fourth generation, hardware technology

such as silicone chips, microprocessors, and

storage devices were invented.

Microprocessor is developed for computer memory

and logic.KEY FEATURES :Portable Computers

developed.

Great Development in data

communication.

Input and Devices : Keyboard,

mouse, joysticks , speakers etc.

REMARKS :Computers costs came down

so rapidly that these found

places at most offices and

homes.

Smaller and faster

More speed , Reliability and

Storage Capacity.

Personal software Industry

Boomed.

Memory : Memory Chips

Storage : Hard disk, Floppy

Page 14: PROGRAM LOGIC AND FORMULATION

SOFTWARE

LESSON 2 All computer programs or routines that

control the function of hardware and affect

data are referred to as SOFTWARE.

Software is a set of electronic instructions

consisting of complex codes (also known as

programs) that make the computer perform

tasks.

Software tells the computer what to do.

There are two major categories of computer

software :

System software & Application Software.

Page 15: PROGRAM LOGIC AND FORMULATION

Systems software

System software exists primarily for the

computer’s use and helps the computer

perform and manage its own task.

One major type of the systems software, the

operating system, (tells the computer how

to use its own components.)

Examples of operating systems include

Windows 98, Windows XP , Mac OS, Linux,

UNIX, OS/2 and DOS.

Page 16: PROGRAM LOGIC AND FORMULATION

Applications

software On the other hand are types of programs

that exist primarily for the use and enable

the computer to perform tasks.

Application software tells the computer how

to accomplish specific tasks, such as world

processing or drawing, for the user.

Examples of popular application programs

are Microsoft Word, Adobe Photoshop,

AutoCAD, and Netscape Navigator.

Page 17: PROGRAM LOGIC AND FORMULATION

PEOPLE

People are the computer operators,

also known as users.

Some computer systems are complete

without a person’s involvement;

however

No computer is totally autonomous.

Even if a computer can do its job

without a person sitting in front of it,

people still building , program , and

repair computer systems.

Page 18: PROGRAM LOGIC AND FORMULATION

data

Data are raw facts that a computer stores and

reads in the form of numbers.

The computer manipulates data according to the

instructions contained in the software and then

forwards it for use by people or another computer.

Data can be letters, numbers, sounds, or images.

No matter what kind of data is entered into a

computer, however, the computer converts it to

numbers. Because of this , computerized data is

digital, meaning that it has been reduced or

represented by digits, or numbers.

Page 19: PROGRAM LOGIC AND FORMULATION

How computers represent

data Computers represent data as numbers. Numbers

, letters, punctuation marks, sounds and

pictures are numbers. Even instructions

performed by the computer are numbers.

People use base 10 to represent numbers. The

system is called base 10 or the decimal number

system because ten symbols are available: 0, 1 ,2

,3, 4, 5, 6, 7, 8, 9.

When you need to represent number greater than

9, you use two symbols together , as in (e.g. 9 + 1

= 10.) Each symbol in a number is called a digit, so

10 is a two-digit number.

Page 20: PROGRAM LOGIC AND FORMULATION

How computers represent

data A computer, however, can only represent data by

the state of its electrical switches. A switch can only

have two possible states – on and off – so it can

represent only two numeric values. To a computer,

when a switch is off, it represents a 0; when a

switch is on, it represents a 1. because there are

only two values, computers are said to function in

base 2, which is also known as the binary number

system.

When a computer needs to represent a quantity

greater than 1m it does the same thing to represent

a quantity greater than 9: it uses two or more digits.

Page 21: PROGRAM LOGIC AND FORMULATION

How computers represent

dataBase 10 Base 2

0 0

1 1

2 10

3 11

4 100

5 101

6 110

7 111

8 1000

9 1001

10 1010

Page 22: PROGRAM LOGIC AND FORMULATION
Page 23: PROGRAM LOGIC AND FORMULATION

The computer program

LESSON 3What is a computer program?

A computer program is a set of

statements or instructions to be fed to

the computer to solve a

computer/computing problem.

These instructions are given and set

by a programmer.

Page 24: PROGRAM LOGIC AND FORMULATION

Character set

LESSON 3 Character set are set of symbols used in the

computer.

Character set has different types which include

data character set, arithmetic operators,

conditional operators, and punctuation

characters.

DATA CHARACTER SET

Data character set is made up of characters

used as data. It is composed of the ff.:

Special Characters ( @ # $ % ^ & etc.)

Numeric Characters ( 0 to 9 )

Alphabetic Characters ( A to Z )

Page 25: PROGRAM LOGIC AND FORMULATION

Character set

LESSON 3 ARITHMETIC OPERATORS

Arithmetic operators are operators used to

perform certain arithmetic operations. Here are

the following arithmetic operators.Symbol Operation

+ Addition

- Subtraction

* Multiplication

/ Division

^ Exponential

\ Integer Division(returns only the whole part)

MOD Modulo Division (returns the remainder)

Page 26: PROGRAM LOGIC AND FORMULATION

Character set

LESSON 3 CONDITIONAL OPERATORS

Used in conditional instructions. Here are the ff.:

Symbol Operation

= Equal to

< Less than

<= Less than equal to

> Greater than

>= Greater than equal to

<> Or >< Not equal

Page 27: PROGRAM LOGIC AND FORMULATION

Character set

LESSON 3 PUNCTUATION CHARACTERS

Are characters that have a special purpose.

Here are examples of punctuation character

and their purpose.

Symbol Use

: (colon) used after procedure labels

, (comma) used to separate enumerations

; (semi-colon) used to terminate instruction

“ (quote) used to enclose string constrain, i.e., “Hello World”

‘ (apostrophe) used to enclose single character, i.e., ‘a’

Page 28: PROGRAM LOGIC AND FORMULATION

Data types

LESSON 3 Information can be classified through Data Types.

Here are some of the data type and their

characteristics.

Data Type Description

Numeric Any information that is composed of numbers

Character Any information composed of singles character enclosed with apostrophe

Date or Time Any information that indicates Data or Time

String Any information composed of any number of characters enclosed with quotes

Page 29: PROGRAM LOGIC AND FORMULATION

Constant

LESSON 3 Constant is a quantity or values which does not

change.

Numeric Constants – any signed or unsigned

numeric value in form of:

Integer (i.e., 1, -1, +1)

Fraction (i.e. 1.0, -1.2, +0.12)

Exponentiation (i.e. 2^2)

Non-numeric or String Constants – any

combination of characters that is enclosed in pair of

quotes. It consists of any combination of characters. Special

characters are also included.

The characters are enclosed in a pair of quotes.

It can accommodate any number of characters.

Page 30: PROGRAM LOGIC AND FORMULATION

Variable

LESSON 3 Variable is a name or symbol that is used as

reference for a value. Rules in using variable

The first letter of the variable name should be any

letter.

If you will use dash(-), it should be embedded. (i.e.

Student-No)

It can accommodate any number of characters

String variable – a variable that stores

string data type. (i.e. FirstName, Address,

StudentNo)

Numeric Variable – a variable that stores

numeric data type (i.e. Age, Counter,

Amount)

Page 31: PROGRAM LOGIC AND FORMULATION

exercises Given the following data types (numeric , date or

time, string, and character). Identify the following

information.

1. ‘c’

2. “my name is rain”

3. 12/20/1979

4. “1234”

5. 1234

6. July 17, 1980

7. ‘g’

8. “December 20, 1979”

9. 1.25

10.8

Page 32: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 There are different kinds of operation

that are being used in a computer

program. They are as follows :

Move Operation

Arithmetic Operation

Conditional Operation

Page 33: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4MOVE OPERATION

Move operation causes the value of

variable to change. The operator used

in this operation is “=”

Example :

StudentName = “Gladys Ordanel”

Age = 15

Amount = 5.00

Page 34: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 ARITHMETIC OPERATION

Arithmetic operation is the evaluation

of arithmetic expression.

Here is an example of an Arithmetic

Expression : 1 + 2 + 3 3 * 4

^ 5 (Age * 6 ) ^ 7

Hierarchy of Arithmetic Operation

In Arithmetic Operation there is a

structure to be followed to know which

arithmetic operation will be resolved

first.

Page 35: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 Here is the hierarchy to be followed

in Arithmetic Operation

1. Expression inside the parenthesis

2. Exponentiation

3. Multiplication and division. (from left

to right)

4. Integer division

5. Modulo division

6. Addition and subtraction. ( from left

to right)

Page 36: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 Example: Evaluate the following

expressions

1. 2 * 2 – 6 / 3

= 4 - 2

= 2

2. 2 * 6 ^ 2 – 20 / 5

= 2 * 36 – 4

= 72 – 4

= 68

3 * (4 + 2) / 2

= 3 * 6 / 2

= 18 / 2

= 9

4. (3 - 2) * 10 MOD 3

= 1 * 10 MOD 3

= 10 MOD 3

= 1

5. 7 \ (3 - 2) ^ 100 MOD 2 * 8

= 7 \ 1 ^ 100 MOD 16

= 7 \ 1 MOD 16

= 7

Page 37: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 CONDITIONAL OPERATION

Conditional Operation is the resolution of

logical expression that arrives on a single

value either TRUE or FALSE.

As addition to operators, here is the logical

operator, its symbol and description.

Symbol Description

AND / OR Binary Operators (Two Operands)

NOT Unary Operator (Single Operand)

Page 38: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 HIERARCHY OF CONDITIONAL

OPERATION

Like the Arithmetic Operation, Conditional

Operation also has a hierarchy to know

which conditional operation will be resolved

first.

Here is the hierarchy to be followed in

Conditional Operation

1. Expression inside the parenthesis

2. NOT operator

3. AND operator

4. OR operator

Page 39: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 Here is the table on how logical

operators generate results.Logical AND Operator

Expr1 Expr2 Result

True True True

False True False

True False False

False False False

Logical OR Operator

Expr1 Expr2 Result

True True True

False True True

True False True

False False False

Logical NOT Operator

Expression Result

NOT True False

NOT False True

Page 40: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 Example: Evaluate the following

expressions

1. T AND T OR F AND F

= T OR F

= T

2. (F OR F) AND NOT (T AND T)

= F AND F

= F

3. F AND NOT T OR T AND NOT F

= F AND F OR T AND T

= F OR T

= T

Page 41: PROGRAM LOGIC AND FORMULATION

OPERATIONS

LESSON 4 COUNTER

Counter is a data storage used for counting.

Usually the incremental value for a counter

is 1. (e.g. ctr = ctr + 1)

ACCUMULATOR

Like a counter, an accumulator is also data

storage for counting but its incremental

value varies and can be stored in to a

variable. (e.g. acc = acc + var)

Page 42: PROGRAM LOGIC AND FORMULATION

Exercises lesson

4 Evaluate the following arithmetic expression.

1. ( 8 / 2 ) ^ 2

2. 8 / 2 ^ 2

3. 6 + 2 – 3

4. 6 / 2 * 3

5. 2 * (2 + 3)

^ 2 Evaluate the following conditional expression.

1. NOT T AND T.

2. NOT T OR T

3. (T OR T) AND F

4. NOT (F AND T ) AND F

5. F AND F OR T AND NOT (F AND T)

Page 43: PROGRAM LOGIC AND FORMULATION
Page 44: PROGRAM LOGIC AND FORMULATION

Pseudo-CODE

LESSON 2