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
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
Computer Science,
3 months ago
Math,
3 months ago
English,
3 months ago
Math,
1 year ago
Psychology,
1 year ago
English,
1 year ago