Solved Examples for an algorithm

1. Write an algorithm to assign the value of a variable to another variable.

The algorithm can be written as:

1. Declare X and Y.
2. Read value for X.
3. Assign value of X and Y.
4. Print value of X and Y.

2. Write an algorithm that prints the smaller of any two given numbers.


Steps : 1. Read two numbers X and Y.
           2. Compare X and Y.
           3. If X is smaller than Y print X else print Y

No comments: