Thursday, 9 June 2011

Solved Examples for an algorithm

Advertisement

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.

Solution:

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


EmoticonEmoticon

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:o
:>)
(o)
:p
:-?
(p)
:-s
8-)
:-t
:-b
b-(
(y)
x-)
(h)