-->

Friday, November 7, 2014

Design an algorithm to find minimum of two distinct numbers

Design an algorithm to find minimum of two distinct numbers

Problem:  Design an algorithm to find minimum of two distinct numbers and using the same, find minimum of three distinct numbers.

Input :  For sub-algorithm 2 numbers and for main algorithm 3 numbers.
Output: Minimum number

MIN_OF_2(NUM1, NUM2)                                                   [Sub-Algorithm]
[NUM1 and NUM2 are two numbers]
If NUM1<NUM2 Then:
Return NUM1
Else:
Return NUM2
[End of If]
Exit

MIN_OF_3(NUM1,NUM2,NUM3)                                     [Main Algorithm]
[NUM1, NUM2, and NUM3 are distinct numbers]
Returns MIN_OF_2(MIN_OF_2(NUM1, NUM2), NUM3)
Exit

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved