3
Contributors
2
Replies
21
Views
1 Year
Discussion Span
Last Post by Raj chanda
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

-1
#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 (); 
}
Votes + Comments
Do not do peoples homework for them
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.