input 5 numbers and print in ascending order in c++

ddanbe commented: Wrong attitude mate. -3
chriswelborn commented: Google 'How to ask smart questions' +0

..Commenting to move from 'Unanswered.'

In the future, you may want to provide more information (such as a small example of what you have tried so far). For now, this article will help you learn how to ask smart questions to get smart answers:

How To Ask Questions The Smart Way

#include<iostream.h>
#include<conio.h>
void main() 
{ 
    int a[5], n, i, j, temp; 
    clrscr(); 
    cout<<"Enter the no. of elements:"; 
    cin>> n; 
    cout<<"Enter the array elements:"; 
    for(i=0; i< n; i++) 
    cin>>a[i]; 
    //------Operation part------- 
    for( i=0; i< n; i++) 
    { 
        for(j=i; j< n-1; j++) 
        { 
            if(a[i]> a[j+1] ) 
            { 
                temp= a[i]; 
                a[i]= a[j+1]; 
                a[j+1]= temp; 
            } 
        } 
    } 

    cout<<"Elements in ascending order:"; 
    for( i=0; i< n; i++) 
    cin>> a[i]; 
    getch (); 
}
commented: Do not do peoples homework for them -3
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.