Computer Science, asked by ruhi668, 11 months ago

JAVA PROGRAM TO ENTER A NUMBER CONTAINING THREE DIGITS OR MORE.ARRANGE THE DIGITS OF THE ENTERED NUMBER IN ASCENDING ORDER AND DISPLAY IT\

Answers

Answered by AdityaRaj200419
5

Java Program to Sort the Array in an Ascending Order

public class Ascending _Order.

int n, temp;

Scanner s = new Scanner(System.

System. out. print("Enter no. of elements you want in array:");

n = s. nextInt();

int a[] = new int[n];

System. out. println("Enter all the elements:");

for (int i = 0; i < n; i++)

Answered by monosijdas82pa9gm5
29

Answer:

import java.util.*;

import java.io.*;

class ArrangeDigit

{

public static void main()

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter the Digits to be arranged");

int n=sc.nextInt();

int d,num=n;

for(int i=0;i<n;i++)

{

num=n;

while(num>0)

{

d=num%10;

if(d==i)

{

System.out.print(d);

}

num=num/10;

}

}

System.out.println();

}

}

Explanation:

Similar questions