C++ program to Sort the Entered Element in array

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
 int x[100],y,j,i,z,v;
 cout<<"Enter size of array:- ";
 cin>>y;
 cout<<"Enter Elements in array:- \n";
 for(i=0;i<y;i++)
 {
  cin>>x[i];
 }
 for(i=0;i<y;i++)
  {
     for(j=i+1;j<y;j++)
      {
       if(x[i]>x[j])
	{
	 v=x[j];
	 x[j]=x[i];
	 x[i]=v;
	}
      }
  }
 cout<<"Sorted array is:- \n";
 for(i=0;i<y;i++)
  {
   cout<<x[i]<<endl;
  }

 getch();
}

OUTPUT:-

sort

1 comment on “C++ program to Sort the Entered Element in array

Leave a Reply

Your email address will not be published. Required fields are marked *