0% found this document useful (0 votes)
25 views18 pages

Week 2

The document discusses algorithms, including defining an algorithm as a set of step-by-step instructions to solve a problem. It explains that algorithms can be represented through pseudocode or flowcharts and provides examples of each. The key steps for designing an algorithm are to understand the overall goal and individual stages to reach that goal. Common notations used in algorithms are also outlined. An activity is presented to design a pseudocode and flowchart that asks users for their best subject.

Uploaded by

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

Week 2

The document discusses algorithms, including defining an algorithm as a set of step-by-step instructions to solve a problem. It explains that algorithms can be represented through pseudocode or flowcharts and provides examples of each. The key steps for designing an algorithm are to understand the overall goal and individual stages to reach that goal. Common notations used in algorithms are also outlined. An activity is presented to design a pseudocode and flowchart that asks users for their best subject.

Uploaded by

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

Class-2

ENGN-1310 Computer Programming


Today’s Agenda
01 02 03
Quick Recap Algorithm Designing
Algorithms
Learning Objectives:
1. To understand what an algorithm is and the
different ways to write them.
2. To understand the usefulness of pseudocode
and flowcharts in designing algorithms.
02
Algorithm
Pseudocode, flowcharts, Designing Algorithms
What is a computer algorithm?

• A set of step-by-step
instructions to solve a
problem.
• They are written as a flowchart
or in pseudocode.
Representing an
Algorithm
Types of representations
Pseudocode Flowcharts

• It is not a programming • A flowchart is a diagram


language. that represents a set of
• Instructions are written in instructions.
uppercase, variables in • Standard symbols are used
lowercase and messages in to represent the different
sentence case. instructions.
Example of Pseudocode
Example of flowchart
Designing an Algorithm
When designing an algorithm there are two main areas to
look at:
• The big picture - What is the final goal?

• The individual stages – What hurdles need to be overcome


on the way to the goal?
What are the basic steps to
understand problem?
What are the inputs into the problem?

What will be the outputs of the


problem?

In what order do instructions need to be


carried out?

What decisions need to be made in the


problem?

Are any areas of the problem repeated?


Most widely used notations:

INPUT
OUTPUT
WHILE – a loop (iteration that has a condition at the
beginning)
FOR – a counting loop (iteration)
REPEAT – UNTIL – a loop (iteration) that has a condition at
the end
IF – THEN – ELSE – a decision (selection)
ACTIVITY
Design a pseudocode and a flowchart that asks people
what is the best subject they take.
REPEAT

OUTPUT 'What is the best subject you take?'

INPUT user inputs the best subject they take

STORE the user's input in the answer variable

IF answer = 'Computer Science' THEN

OUTPUT 'Of course it is!'

ELSE

OUTPUT 'Try again!'

UNTIL answer = 'Computer Science’

You might also like