KEMBAR78
Algo FlowChart | PDF | Computer Programming | Algorithms
0% found this document useful (0 votes)
25 views14 pages

Algo FlowChart

The document outlines the software development process, detailing phases from problem definition to maintenance, and emphasizes the importance of algorithms in programming. It describes techniques for representing algorithms, such as flowcharts and pseudocode, and highlights the characteristics and building blocks of algorithms. Additionally, it includes examples and assessments related to programming concepts and algorithms.

Uploaded by

kobhy
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)
25 views14 pages

Algo FlowChart

The document outlines the software development process, detailing phases from problem definition to maintenance, and emphasizes the importance of algorithms in programming. It describes techniques for representing algorithms, such as flowcharts and pseudocode, and highlights the characteristics and building blocks of algorithms. Additionally, it includes examples and assessments related to programming concepts and algorithms.

Uploaded by

kobhy
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/ 14

Software Development Model helps developer to select a strategy to develop the software.

These are few


software development paradigms or process models water fall, iterative model, spiral model, v-model, big
bang model, etc.
3. Algorithm Development (Phase 3)
The developer develops a systematic procedure to solve the problem using the specification given in the
previous phase. The algorithm can be developed using:

• Draw flowchart – graphical representation of step-by-step instruction to be done in a


program.
• Write a pseudo code – list down the set of instructions to be used in the program.

4. Coding (Phase 4)
This phase uses a programming language (like C, C++, Java, PHP, etc.) to write or implement actual
programming instructions for the steps defined in the previous phase.
5. Testing & Debugging (Phase 5)
The developer checks whether the code written in previous step is solving the specified problem or not.
The developer also tests whether it is producing the desired output or not.
6. Documentation, Implementation and Maintenance (Phase 6)
During this phase (documentation), the programmer makes a detailed description on how the program
was created. It contains a brief narrative process undergone by a program. In these steps (maintenance),
the users actively use the program. If any enhancements found in this phase, all the phases are to be
repeated again to make the enhancements. That means in this phase, the end user uses the solution
(program).
NB: It can be in order of five stages as follows: (1) Define and analyse the problem, (2) Design a method of
solution using flowchart and or pseudocode, (3) Write the programme in a suitable programming
language, (4) Test and Debug the program, (5) Document, implement and maintain the programme.

ALGORITHMS
In programming, algorithm is a set of well-defined instructions in sequence to solve the problem.
Algorithm is a logical sequence of steps for solving a problem, often written out as a flow chart that can be
translated into a computer program. It can also be defined as a step-by-step procedure to solve a given
problem. A recipe in a cookbook is an excellent example of an algorithm.
Characteristics of an Algorithm

• Input and output should be defined precisely.


• Each step in algorithm should be clear and unambiguous.
• Algorithm should be most effective among many different ways to solve a problem.

176
• An algorithm shouldn't have computer code. Instead, the algorithm should be written in such a
way that, it can be used in similar programming languages.

Examples of Algorithms in Programming


Write an algorithm to add two numbers entered by user.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop

TECHNIQUES FOR REPRESENTING ALGORITHMS


In the problem-solving phase of computer programming, you will be designing algorithms. These
algorithms can be designed using flowcharts and pseudo code.
Pseudo Code
Is a generic way of describing an algorithm without use of any specific programming language syntax. It
cannot be executed on a real computer, but it models and resembles real programming code, and is
written at roughly the same level of detail.
Example
READ name, hourlyRate, hoursWorked, deductionRate
GrossPay = hourlyRate * hoursWorked
Deduction = grossPay * deductionRate
NetPay = grossPay – deduction
WRITE name, grossPay, deduction, netPay
Flow Charts
Is a diagrammatic representation of an algorithm, workflow or process. A flow chart is a diagram made up
of boxes, diamonds and other shapes, connected by arrows – each shape represents a step in the process,
and the arrows shows the order in which they occur.
Flow Charting Symbols
There are 6 basic symbols commonly used in flowcharting namely Terminal, Process, Input/Output,
Decision, Connector and Predefined Process.

177
Symbol Name Function
Indicates any type of internal operation
Process inside the Processor or Memory like data
transformation, data movement, logic
operation, etc.
Used for any Input/Output operation.
Input/Output Indicates that the computer is to obtain
data or output result.

Used to ask questions that can be


Decision answered in a binary format (Yes/No,
True/False)

Connects sections of flowchart, so that


Connector the diagram can contain a smooth, linear
flow.

Indicates the starting or ending of a


Terminator program, process or interrupt program.

Shows direction of flow


Flow Lines

Used to invoke a subroutine or an


Predefined process interrupt program

General Rules for flowcharting


1. All boxes of the flowchart are connected with arrows. (Not lines)
2. Flowcharts symbols have an entry point on the top of the symbol with no other entry points. And
the exit point is always at the bottom except for Decision symbol.
3. The decision symbol has two exit points, these can be on the side or the bottom and one side.
4. Connectors are used to connect breaks in the flowchart. Examples are;
• From one page to another.
• From the bottom of the page to the top of the same page.
5. Subroutines and Interrupt programs have their own and independent flowcharts.
6. All flowcharts start with a Terminal or Predefined Process (for interrupt programs or subroutines)
symbol.
7. All flowcharts end with a terminal or a contentious loop.
178
Factors to Consider in Constructing Flowcharts
1. Think through the problem solution step-by- step.
2. Analyse the specifications in terms of
• the required inputs
• the output desired
• the operations and procedures required to produce the output
3. Clarify the problem by having a narrative definition of the problem definition
4. Develop a flowchart showing the logic, steps, and sequence of steps you want the computer to
execute in order to solve the problem.
ALGORITHM BUILDING BLOCKS
All problems can be solved by employing any one of the following building blocks or their combinations.
1. The Sequence Structure
The sequence structure is a case where the steps in an algorithm
are constructed in such a way that, no condition step is required.
The sequence structure is the logical equivalent of a straight line.
For example, suppose you are required to design an algorithm for
finding the average of six numbers, and the sum of numbers
given, The Pseudo code will be as follows;
Start
Get sum
Average = sum/6
Output the average
Stop

2. Decision Structure / Selection Structure (Conditional)


It is a structure where in the algorithm, one has to
make a choice of two alternatives by making decision
depending on a given condition. Example, In the
Pseudo code and flowchart form;
If condition is True
Then do task A
Else
Do Task B
In this example, the condition is evaluated, if the
condition is True Task-A is evaluated and if it is False,
then Task-B is executed.

179
Types of Flowcharts
1. Data Flow Diagram (DFD)
DFD reveal relationships among and between the various components in a program or system. DFDs
consists of four major components: entities, processes, data stores, and data flows.
2. System Flowcharts
System flowcharts are a way of displaying how data flows in a system and how decisions are made to
control events.

Example of Algorithm and Flowchart


1. Algorithm & Flowchart to find the sum of two numbers.

A: First Number

B: Second Number

Algorithm

Step 1: Start

Step 2: Input two numbers A & B

Step 3: SUM = A + B

Step 4: Output SUM

Step 5: Stop

180
2. Algorithm & Flowchart to convert temperature from Celsius to
Fahrenheit.

C: Temperature in Celsius

F: Temperature in Fahrenheit

Algorithm

Step 1: Start

Step 2: Input C

Step 3: F = (9.0/5.0 * C) + 32

Step 4: Output “Temperature in Fahrenheit is” F

Stop 5: Stop

3. Algorithm & Flowchart to find Area and Perimeter of Square.

L: Side Length of Square

Area: Area of Square

Perimeter: Perimeter of Square

Algorithm

Step 1: Start

Step 2: Input L

Step 3: Area = L * L

Step 4: Perimeter = 4 * L

Step 5: Output “Area is” Area, “Perimeter is” Perimeter

Step 6: Stop

181
4. Algorithm & Flowchart to find Simple Interest.

P: Principal Amount

N: Time in Years

R: % Annual Rate of Interest

SI: Simple Interest

Algorithm

Step 1: Start

Step 2: Input value of P, N, R

Step 3: SI = (P x N x R)/100.0

Step 4: Output “Simple Interest is ” SI

Step 6: Stop

5. Algorithm & Flowchart to find the largest of


two numbers.

NUM1: First Number

NUM2: Second Number

Algorithm

Step 1: Start

Step 2: Input two numbers say

NUM1, NUM2

Step 3: IF NUM1 > NUM2 THEN


Output “largest is ” NUM1
ELSE
Output “largest is “ NUM2
182
ENDIF
Step 4: Stop

6. Algorithm & Flowchart to find the largest of three numbers.

Num1: First Number

Num2: Second Number

Num3: Third Number

Algorithm

Step 1: Start

Step 2: Read three numbers say num1, num2, num3

Step 3: If num1>num2 then go to step-5

Step 4: IF num2>num3 THEN

Output num2 “ is largest”


ELSE
Output num3 “ is largest”
ENDIF
GO TO Step-6

Step 5: IF num1>num3 THEN

Output num1 “ is largest”

ELSE

Output num3 “ is largest”

ENDIF

Step 6: Stop

183
7. Algorithm & Flowchart to find Even number between 1 to 50.

Algorithm

Step 1: Start

Step 2: I = 1

Step 3: IF (I >50) THEN


GO TO Step-7
ENDIF
Step 4: IF ( (I % 2) =0) THEN
Display I
ENDIF
Step 5: I = I + 1
Step 6: GO TO Step--3

Step 7: Stop
184
TRIALS

a. Algorithm & Flowchart to find Area and Perimeter of Rectangle.


b. Algorithm & Flowchart to find Area and Perimeter of Circle.
c. Algorithm & Flowchart to find Area & Perimeter of Triangle. [when three sides are given]
d. Algorithm & Flowchart to find Compound Interest.
e. Algorithm & Flowchart to find Odd numbers between 1 to 50.

185
LESSON ASSESSMENT
OBJECTIVES
1. One of the characteristics of machine language is that
A. It uses mnemonic code
B. Each computer has its own machine language
C. It uses simple words that are easy to remember
D. It uses complex words that are difficult to remember
2. The first compiled programming language was
A. C++
B. FORTRAN
C. Pascal
D. Visual Basic
3. The rules of a programming language is called
A. Documentation
B. Source code
C. Pseudocode
D. Syntax
4. Keywords used in pseudocode programming include:
I. DO UNTIL
II. SELECT
III. END IF
IV. IF
A. I, II and III only
B. I, III and IV only
C. II, III and IV only
D. I, II, III and V
5. Examples of object-oriented programming languages include:
I. COBOL
II. JAVA
III. BASIC
IV. C++
Which of the following options are correct?
A. I and III only
B. II and III only
C. II and IV only
D. III and IV only
6. Which of the following options contains computer instructions?
A. Audio
B. Data
186
C. Program
D. Video
The following below shows an algorithm for printing the numbers inclusive. Certain statements of the
algorithm have been represented with the letters P and Q.
Use the flowchart below to answer questions 7 to 10.

7. The name of the symbol labelled K is


A. Data
B. Decision
C. Flow line
D. Terminator
8. The name of the symbol labelled Q
A. Decision
B. Flow line
C. Input/Output
D. Process
9. Which condition should be placed in P in order for the algorithm to function correctly?
A. J < 10
B. J <= 10
C. J >10
D. J >= 10
10. The correct statement to be placed in Q in order to update the value of the variable J to enable the
algorithm to function correctly is
A. J = 1 – J
187
B. J = 1 + J
C. J = J – 2
D. J = J + 2
11. The computer programming language specifically developed for business solutions is
A. ADA
B. BASIC
C. COBOL
D. FORTRAN
12. Finite number of sequential instructions is called
A. Algorithm
B. Control flow
C. Flowchart
D. Program flow
13. The term class in object-oriented programming refers to
A. A constant
B. A variable
C. A collection
D. An instance of an object
14. Which of the following programs is an object-oriented programming language?
A. ADA
B. C
C. FORTRAN
D. RUBY
15. Which of the following is a 2GL in computer languages?
A. COBOL
B. Assemble Language
C. Machine Language
D. High Level Language

SUBJECTIVES

1. State, in order, five stages involved in the development of a computer program.

2. A) What is an algorithm?

B) Write an algorithm to convert a temperature in Celsius (C) scale to Fahrenheit (F) scale.

NB: f= 9/2 C + 32.

188
3. A) Write an algorithm to find the largest of three numbers.

B) Draw a flowchart to represent the algorithm in 3 (a).

4. A) Differentiate between the two categories of programming language.

B) Define the following;


I. Computer Programming
II. Computer Program
III. Programming Language

189

You might also like