A five-digit number is entered through the keyboard. Write a program which will re order the digits of the number from smallest to highest. Like, if you enter 54231 the program will show output as 12345. help me.

Recommended Answers

All 5 Replies

Help you with what? You didn't give us a clue what kind of help you need.

I have been doing programming in C and C++ for two years. I fetch so many problems regarding to global variable and function prototype as well as return value. Try to do coding less complexity as possible as you can. use function to create a task.

ROFLMAO - 2 years, and you can't do this brain-dead exercise.

My idea is you're just another drive-by recycling rubbish from other forums so you can spam your sig-link.

bubblesort

ya Bubble short is the best way.
# program for bubble short:

void bubble(int a[],int n)  
   {  
         int i,j,t;  
          for(i=n-2;i>=0;i--)  
          {  
             for(j=0;j<=i;j++)  
   
                   {  
                     if(a[j]>a[j+1])  
                                     {  
                                       t=a[j];  
                                      a[j]=a[j+1];  
                                      a[j+1]=t;  
                                     }  
                    }  
          
   
            }  
   
   }
   
   
   void main()  
   {  
   
       int a[100],n,i;  
   
    
   
       printf("Enter integer value for total no.s of elements to be sorted: ");  
       scanf("%d",&n);  
   
       for( i=0;i<=n-1;i++)  
             { printf("\n\n Enter integer value for element no.%d : ",i+1);  
               scanf("%d",&a[i]);  
             }  
   
        bubble(a,n);  
   
        printf("\n\n Finally sorted array is: ");  
        for( i=0;i<=n-1;i++)  
       printf("%3d",a[i]);  
   
 } //end program.
commented: Spoon-fed, unformatted, non-standard code - ugh! -4

Bad formatting, non-standard code.

Basically a bad post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.