C++ Programming Blog

 
 
 

Image

# include <iostream.h>
# include <conio.h>

void main()
{
    clrscr();
    int a[50],size;
    cout<<\"Enter Size of an Array :\";
    cin>>size;
    for(int i=0;i<size;i++)
    {
        cout<<\"Enter Value of a[\"<<i<<\"] :\";
        cin>>a[i];
    }
    for(i=0;i<size;i++)
    {
        for(int j=0;j<size-(i+1);j++)
        {
            if(a[j] > a[j+1])
            {
                int t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
    cout<<\"Sorted List ...\"<<endl;
    for(i=0;i<size;i++)
    {
        cout<<endl;
        cout<<\"a[\"<<i<<\"] :\"<<a[i];
    }
    getch();
}