Program for Selection sort


#include<iostream>          // selection sort code in c++
#include<iomanip>
using namespace std;
int main()
{
 int i,j,k,n;
 cout<<"\nenter the no of integers : ";
 cin>>n;
 long signed int a[n],temp;
 cout<<"\nenter the integers : ";
 for(i=0;i<n;i++)
 {
  cin>>a[i];
 }
 cout<<"\narray before sorting : ";
 for(i=0;i<n;i++)
 {
  cout<<a[i]<<" ";
 }
 for(i=0;i<(n-1);i++)
 {
  for(j=i+1;j<n;j++)
  {
   if(a[i]>a[j])
   {
    temp=a[i];
    a[i]=a[j];
    a[j]= temp;
   }
  }
 }
 cout<< "\narray after sorting :";
 for(i=0;i<n;i++)
 {
  cout<< a[i]<< " ";
 }
return 0;
}