0% found this document useful (0 votes)
18 views

Week-4-Algorithm-and-Pseudocode

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Week-4-Algorithm-and-Pseudocode

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Algorithm and Pseudocode

Algorithm and Pseudocode are the two related terms in computer programming. The basic difference
between algorithm and pseudocode is that an algorithm is a step-by-step procedure developed to solve a
problem, while a pseudocode is a technique of developing an algorithm.

Activity

ATM BALANCE INQUIRY


This algorithm outlines a simple balance inquiry process at an Automated Teller Machine, arrange them
correctly according to step-by-step process by putting numbers 1-7 in the space provided.
1. _____The account balance is displayed to the user.
2. _____If the user chooses to exit, a farewell message is displayed.
3. _____The user is given the option to perform another transaction or exit.
4. _____If the PIN is valid, the ATM connects to the bank's database to fetch the account balance.
5. _____The user is prompted to insert their ATM card.
6. _____If the user chooses to perform another transaction, the process starts over.
7. _____If the card is inserted, they are prompted to enter their 4-digit PIN.

ATM WITHDRAWAL TRANSACTION


This algorithm outlines a simple withdrawal process at an Automated Teller Machine, arrange them correctly
according to step-by-step process by putting numbers 1-8 in the space provided.
1. _____If the transaction is successful, the account balance is updated, cash is dispensed, and the user is
given the option to perform another transaction or exit.
2. _____If the withdrawal amount is valid and within the account balance, the transaction proceeds.
Otherwise, an error message is displayed.
3. _____If the PIN is valid, the ATM connects to the bank's database to fetch the account balance and
displays it.
4. _____The user is prompted to insert their ATM card.
5. _____If the user chooses to perform another transaction, the process starts over.
6. _____If the user chooses to exit, a farewell message is displayed.
7. _____If the card is inserted, they are prompted to enter their 4-digit PIN.
8. _____The user is asked to enter the amount they want to withdraw.

Algorithm
A sequence of steps to solve a given problem is called as algorithm. Thus, an algorithm is a step-by-step
procedure developed for solving a given problem. An algorithm consists of sequences, iterations, selections,
etc. The selection of an algorithm depends upon the nature of the given problem. Thus, the problem is first
analyzed, and then the best algorithm is used to solve it.

An algorithm follows a systematic and a logical approach, where the procedure is defined step-wise. In an
algorithm, many simple operations are combined to help form a more complicated operation, which is
performed with ease by the computer. Characteristics of a good algorithm include:

 Input: It should accept inputs.


 Output: It should produce outputs.
 Definiteness: Each step should be precisely defined.
 Finiteness: It should terminate after a finite number of steps.
 Effectiveness: Each step should be simple and feasible to execute.

Algorithm and Pseudocode Page 1 of 2


Example of an Algorithm
Problem: Compute and display the average of 3 numbers
Steps:
1. Input value for the 1st number
2. Input value for the 2nd number
3. Input value for the 3rd number
4. Add the value of 3 numbers to get the sum
5. Divide the sum by 3 to get the average
6. Display the value of the average

Pseudocode
Is an informal method of developing an algorithm. Thus, computer programmers use simple informal language
to write a pseudocode. It does not have any specific syntax to follow. The pseudocode is a text based design
tool. Basically, pseudocode represents an algorithm to solve a problem in natural language and mathematical
notations.

Pseudocodes are written in plain English, and they use short phrases to represent the functionalities that the
specific lines of code would do. Since there is no strict syntax to follow in pseudocode writing, they are
relatively difficult to debug.

Example of Pseudocode
Problem: Compute and display the average of 3 numbers
Steps:
1. Input num1
2. Input num2
3. Input num3
4. sum = num1 + num2 + num3
5. average = sum / 3
6. Display average

Key Differences:
 Algorithm is a general concept referring to a step-by-step procedure.
 Pseudocode is a way to express the steps of an algorithm in a structured but informal manner.
Both are essential for planning and communicating logic before writing actual code.

References:
https://www.tutorialspoint.com/difference-between-algorithm-and-pseudocode

Algorithm and Pseudocode Page 2 of 2

You might also like