Data Structures and Algorithms: An Introduction 81
AlgorithmPrint_Table Ver3.
{
Step
1. Row = 1
2. Col = 1
2.1 Print the col.
2.2 Col = Col + 1
2.3 If Col <= 10 repeat steps 2.1 and 2.2
2.4 Go to a new line.
3. Row = Row + 1
4. If Row <=10 repeat steps 2 and 3
5. Stop.
}
Now our concern is “how to print a column”. We find that it is very simple, i.e., we get the value to be
printed by multiplying the values contained in the variables Row and Col. The final version of the refined
algorithm is given below:
AlgorithmPrint_Table Ver4.
{
Step
1. Row = 1
2. Col = 1
2.1 ColVal = Row * Col
2.2 Print the ColVal.
2.3 Col = Col + 1
2.4 If Col <= 10 repeat ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.