0% found this document useful (0 votes)
29 views9 pages

Lecture # 05 (B) : Lecturer: E-Mail

The document discusses algorithms, including definitions, properties, and methods of specifying algorithms. It also covers flowcharting symbols and provides examples of algorithm problems.

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views9 pages

Lecture # 05 (B) : Lecturer: E-Mail

The document discusses algorithms, including definitions, properties, and methods of specifying algorithms. It also covers flowcharting symbols and provides examples of algorithm problems.

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Lecture # 05(b)

Lecturer: Muhammad Abdullah Azhar

E-mail: [email protected]
 It is a list of instructions specifying a precise description
of a step by step process that terminates after a finite
number of steps for solving an algorithm problem
producing the correct answer in the end.

 It is a recipe for solving problems.

 A finite set of an instruction that specifies a sequence of


operation to be carried out in order to solve a specific
problem.

 An unambiguous procedure specifying a finite number of


steps to be taken.
METHODS OF SPECIFYING ALGORITHM

 Pseudocode - specifies the steps of algorithm using


essentially natural language of superimposed control
structure.

 Flowchart - a traditional graphical tool with standardized


symbols. Show the sequence of steps in an algorithm.
PROPERTIES OF ALGORITHM
 Finiteness - there is an exact number of steps to be taken and has
an end.

 Absence of Ambiguity - means that every instruction is precisely


described and clearly specified.

 Sequence of Execution - instructions are performed from top to


bottom.

 Input and Output - defined the unknowns of the problem is


specified and with the expected outcome.

 Effectiveness - the solution prescribed is guaranteed to give a


correct answer and that the specified process is faithfully carried
out.

 Scope Definition - applies to a specific problem or class of


problem.
1. State the problem clearly- a problem cannot be solved
correctly unless it is being understood.

2. Plan and Write the Logical Order of Instructions - the


computer follows the direction exactly at the given sequence.

3. Code the Program - write the programming statements in the


desired language.

4. Enter the program into the computer - key in or type the


statement into the computer.

5. Run and Debug the program - check if you have the desired
output; if not, trace the possible error.
1. The flowchart should flow from top to bottom

2. If the chart becomes complex, utilize connecting blocks

3. Avoid intersecting flow lines

4. Use meaningful description in the symbol


Flowcharting Symbols

SYMBOL NAME DESCRIPTION


Defines the starting
TERMINAL and ending point of
a flowchart.
The preparation or
INITIALIZATION initialization of
memory space for
data processing.
The inputting of data
INPUT/OUTPUT for processing, and
printing out of
processed data.
Manipulation of
data(assignments
PROCESS and mathematical
computations)
Flowcharting Symbols
SYMBOL NAME DESCRIPTION
Defines logical
FLOW LINES sequence of the
program. Its points to
the ext symbol to be
performed
Connects to the
ON-PAGE CONNECTOR flowchart to avoid
spaghetti connection
on the same page

Connects the flowchart


OFF-PAGE CONNECTOR on different page to
avoid spaghetti
connection

Process conditions
DECISION using relational
operators. Used for
trapping and filtering
data.
SAMPLE EXERCISES

Sample 1: Write a program that calculates the sum of two input numbers and
display the result.

Sample 2: Write a program to calculate the area of a circle and display the
result. Use the formula: A=πr2 where Pi is approximately equal to 3.1416.

Sample 3: Write a program that computes the average of three input quizzes,
and then display the result.

Sample 4: Write a program that converts the input Fahrenheit degree into its
Celsius degree equivalent. Use the formula: C= (5/9)*F-32.

Sample 5: Create a program to compute the volume of a sphere. Use the


formula: V= (4/3)* πr3 where is pi equal to 3.1416 approximately. The r3 is
the radius. Display result.

Sample 6: Write a program that converts the input Celsius degree into its
equivalent Fahrenheit degree. Use the formula: F= (9/5) * C+32.

You might also like