Computer Science, asked by tayab5013, 10 months ago

Write a program to find the smallest digit in an integer in Java

Answers

Answered by prashantrohilla32
6

Answer:

import java.util.*;

import java.lang.*;

import java.io.*;

public class Main {

public static void main (String[] args) {

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

int temp=n;

  int s=10;

   

  while(n>0)

  {

      int r=n%10;

      n=n/10;

      if(r<s)

      {

          s=r;

      }

  }

  System.out.println("Smallest digit in " +temp+" = "+s);

     

}

         

}

     

     

Explanation:

Attachments:
Answered by divyansh05887
3

Answer:

Your Answer Is Attached here

HOPE IT HELPS...

Attachments:
Similar questions