Hi friends,Good Evening.
how to display numbers in ascending order in a given integer number.
input : int number=4657
output should be : 4567
please give your solutions.
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 13, 2015, 7:18 AM EDT
int I = 0;
Console.WriteLine("Enter Your Number");
int.TryParse(Console.ReadLine(), out Num);
Loc=Num;
int [] Arr=new int [Loc.ToString().Length];
while (Loc != 0)
{
Arr[I] = Loc % 10;
Loc = Loc / 10;
I++;
}
Array.Sort(Arr);
Num = 0;
for (int i = 0; i < Arr.Length; i++)
{
Num += Arr[i] * Convert.ToInt32(Math.Pow(10, Arr.Length - i - 1));
}
Console.WriteLine(Num.ToString());
Console.ReadLine();