Algorithm Design
Algorithm Design
Pseudocode
Algorithm
• A process or set of rules to be followed in calculations or other
problem-solving operations, especially by a computer is
known as Algorithm.
• It is good practice to use constants if this makes the pseudocode more readable,
as an identifier is more meaningful in many cases than a literal. It also makes the
pseudocode easier to update if the value of the constant changes.
• Constants are declared by stating the identifier and the literal value in the
following format:
• The integer division operators MOD and DIV can be used. However, their
use should be explained explicitly and not assumed.
WHILE <condition> DO
<statements>
ENDWHILE
INPUT NUM
WHILE NUM >9 DO
NUM=NUM-9
END WHILE
REPEAT… UNTIL
• Post Conditional Loop.
• The actions are only repeated WHILE a given condition is False.
• The action in the loop will continue until the condition is True.
• The actions in this loop are always completed at least once.
REPEAT
<Statements>
UNTIL <condition>
INPUT NUM
REPEAT
NUM=NUM-9
UNTIL NUM<9
Difference between
WHILE … DO… END WHILE and REPEAT… UNTIL
Comparison between FOR … TO … NEXT, WHILE … DO… ENDWHILE and REPEAT… UNTIL
Comparison of different Loops using Pseudocode
Features to make a pseudo code more
understandable:
• Indentation
• Meaningful identifier Names
• Comments.
Sequence
Sequence is the concept of one statement being
executed after another. Example:
INPUT NUM1
INPUT NUM2
TOTAL=NUM1+NUM2
OUTPUT TOTAL
Frequently Asked Question
Q1. Write the names of two Selection or conditional
statement.
Q2. Write the names of three loop structure.
Q3. Explain two selection statements with example.
Q4. Explain three loops with example.
Q5. Write names of arithmetic and relational operation.
Q6. List three logical operators.
Q7. How to make a program more understandable?
Q8. Explain Counting, Totaling, Sequence and Selection with
example.