Write an algorithm to find the minimum of numbers where N is any arbitary natural number. N is given to you by the user as the first value.

Showing Answers 1 - 5 of 5 Answers

hkasthuri

  • Nov 22nd, 2007
 

Algorithm smallestnumber
Input : N, any arbitary natural number within which the smallest number should be found
Output : Smallest number

Min <- I0
While I < N do
    if I < Min then min <- I
    Increment I by 1
Loop
return Min

  Was this answer useful?  Yes

N is given to you by the user as the first value.


Solution

Input:: N
Output:: min

int temp = N;
int digit;
int min = 10;
while(temp>0){
    digit = temp%10; // Find the last digit.
    if(min>digit) min = digit;
    temp = temp/10;
}

  Was this answer useful?  Yes

prakash_om

  • Jul 6th, 2010
 

Algorithm: Minimum of n numbers
Intput: a[1...n] an array of integers
Output: Minimum number

Step1:        Minimum=a[1]
Step2:        For i=1 to n do
Step3:        if(a[i]<Minimum)
Step4:        Minimum=a[i]
Step5:        return Minimum
         

  Was this answer useful?  Yes

jjtharappel

  • Nov 23rd, 2011
 

I = N / 10
J = I * 10
K = N - J
min_num = K

If I > 10
Do while I < 10
N = I
I = N / 10
j = I * 10
K = N - J
if K < min_num
min_num = K
end-if
end-do

Prinf "Minimum number is " min_num
Return

  Was this answer useful?  Yes

jjtharappel

  • Nov 24th, 2011
 

The one I posted on Nov23 will not sork. A slight modification. Below is the working code

Code
  1. span style="color: #ff0000;">"MINIMUM DIGIT OF NUMBER "" IS ""INPUT NUMBER NOT NUMERIC, PUT 10 DIGIT NUMBER"


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions