Computer Science, asked by ayeshajung5, 7 months ago

Write a program to accept a number and find the smallest digit of an integer that is input.
Sample Input : 6524
Sample Output : 2


Spammers will be reported

Answers

Answered by parimalahire18
28

Answer:

Explanation:

import java.util.Scanner;

public class smallestdigit

{

   public static void main(String args[])

   {

       int store, digit;

       Scanner in=new Scanner(System.in);

       System.out.println("Enter The Number");

       int n=in.nextInt();

       store = n%10;      // extracting a initial value to be stored  

       n=n/10;            // removing the value which is already stored;

       while(n>0)

       {

           digit=n%10;

           if(digit<store)

           {

               store= digit;

           }

           n=n/10;

       }

       System.out.println("Smallest Digit is :"+store);

   }

}

Similar questions