Skip to main content

Write a program to accept a number. Display the digits of the numbers in ascending order.




/**
Write a program to accept a number. Display the digits of the numbers in ascending order. 
*/
import java.util.Scanner;
class digitsAscending
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number:");
int n = sc.nextInt();
int m=n;
System.out.println("Digits in ascending order");
for(int i=0;i<=9;i++)
{
while(n>0)
{
int d=n%10;
if(d==i)
System.out.print(i);
n=n/10;
}
n=m;
}
}
}

Popular posts from this blog