WAP to Find the Maximum and Minimum Digit given by the user
import java.util.*;
class smalldigitmaxdigit
{
public static void main(String args[])
{
int a,n,d,min,max;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the no");
n=sc.nextInt();
min=max=n%10;
while(n!=0)
{
d=n%10;
if(d>max)
{
max=d;
//System.out.println("Maximum="+max);
}
else if(d<min)
{
min=d;
//System.out.println("Minimum="+min);
}
n=n/10;
}
System.out.println("Maximum="+max);
System.out.println("Minimum="+min);
}
}
class smalldigitmaxdigit
{
public static void main(String args[])
{
int a,n,d,min,max;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the no");
n=sc.nextInt();
min=max=n%10;
while(n!=0)
{
d=n%10;
if(d>max)
{
max=d;
//System.out.println("Maximum="+max);
}
else if(d<min)
{
min=d;
//System.out.println("Minimum="+min);
}
n=n/10;
}
System.out.println("Maximum="+max);
System.out.println("Minimum="+min);
}
}
Comments
Post a Comment