Search

Friday, November 7, 2014
0 comments

Design an algorithm to find minimum of two distinct numbers

7:34 PMFriday, November 7, 2014
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

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top