Simple Algorithms - basic calculations
Conditional Algorithms - selection statements
Algorithms are series of instructions that rigorously defines the solution to a problem.
The attributes of an algorithm are:
- Must be precise
- Must be ambiguous
- Must be finite
- Must be done in a logical order
Example of given problem:
Write an algorithm that prompts the user to enter two grades, and shows the average of the two grades.
Indicators that it is a simple algorithm: basic calculation of entering data, performing calculation, and outputting results.
Solution:
Print "Enter a grade"
Input grade1
Print "Enter another grade"
Input grade2
Let total = grade1 + grade2
Let avg = total / 2
Print "The average of two grades is", avg
Input key
No comments:
Post a Comment