1 - Program Logic Formulation
1 - Program Logic Formulation
1 - Program Logic Formulation
Avo
What is a COMPUTER PROGRAM?
a set of instructions for a computer.
receives data, carry out the instructions,
and
produce useful results.
What is COMPUTER PROGRAMMING?
shortened as PROGRAMMING or CODING.
the process of writing, testing,
debugging/troubleshooting, and maintaining
the source code of computer programs.
What is PROGRAMMING LANGUAGE?
an artificial language that can be used to
write programs which control the behavior of
a machine, particularly a computer.
defined by syntactic and semantic rules
which describe their structure and meaning
respectively.
they have some form of written
specification of their syntax and semantics.
What is a PROGRAMMER?
is a person who prepares instructions for
computers.
receives directions from a systems analyst.
also known as software developer.
write, test and maintain the detailed
instructions (computer programs), that
computers must follow to perform their
functions.
The First Programmer
Ada Lovelace
Countess of Lovelace (10 December 1815 27 November 1852)
Born Augusta Ada Byron, was an English writer
chiefly known for her work on Charles Babbage's
early mechanical general-purpose computer, the
analytical engine.
Her notes on the engine include what is
recognised as the first algorithm intended to be
processed by a machine
She is portrayed in popular culture as the "World's
First Computer Programmer".
Ada Lovelace
1) Define the Problem
2)Design a Test Plan
3) Design a Solution
Must understand exactly what the
problem is, before we can begin to solve
it.
Must answer such questions as
Which?, How? and What?.
Define the Scope and Generality of the Solution
Needed
Define the Input and Output
Define Constants and Formulas
Define Basic Computational Needs
Verification is an essential step in program
development.
Algorithm:
1. Read an integer A.
2. Display the value of integer A.
Algorithm in computer
Problem: Construct an algorithm to read in
three integers X, Y, Z. Compute the sum of the
three integers then store it to variable SUM.
Display the result.
Algorithm:
1. Read the value of the three integers X, Y,
Z.
2. Compute the sum using the formula
SUM = X+Y+Z.
3. Print SUM.
Exercise:
1.Write the algorithm to compute the average
of three input quizzes.
Decision Symbol
(Diamond)
Bottom to Top
Example 1: Sequence
Write an algorithm to read an integer A then display the value of
the integer.
BEGIN
Algorithm:
1. Read the value of integer A.
2. Display the value of integer A. READ A
Flowchart
PRINT A
END
Example 2 : Sequence
Construct an algorithm to read in three integers X, Y, Z.
Compute the sum of the three integers then store it to variable
SUM. Display the result. BEGIN
Algorithm:
1. Read the value of the READ X, Y, Z
three integers X, Y, Z.
Flowchar
2. Determine the sum t
using the formula SUM SUM = X + Y + Z
= X + Y + Z.
3. Print SUM. PRINT SUM
END
Exercise
A. Write the algorithm and draw the flowchart. Given three
numbers A, B, and C. Compute and print out the sum,
the product and the average of these values.
Letters Colors
B or b Blue
R or r Red
G or g Green
Y or y Yellow
Other letters Unlisted Color
Example:
Initialization
the value of a counter used is initially set equal to 0 or 1.
this process is always done outside the loop.
Test for Limit Conditions
before logic flow gets out of a loop, a loop-terminating condition must
first be satisfied.
the process of testing usually found either at the beginning or at
the end of a loop.
Incrementation
after each loop is executed, 1 is added to the counter.
thus the counter reflects the number of times the operation has been
performed.
note that the process of incrementation is always done within the
loop.
Write the algorithm and draw a
flowchart that will calculate the sum of the
given sequence numbers: 1 2 3 4 5.
That is,
1+2+3+4+5
The sum is: 15
1. Draw a flowchart that determines if the input number is
ODD or EVEN. Odd numbers are 1,3,5,7, and even
numbers are 2,4,6,8,10,