Write a program to sort elements of given array having ‘n’ numbers of elements, using Selection sort.
#include
#include
void main()
{
clrscr();
int size, arr[50], i, j, temp;
cout<>size;
cout<<“Enter Array Elements : “;
for(i=0; i>arr[i];
}
cout<<“Sorting array using selection sort…n”;
for(i=0; i<size; i++)
{
for(j=i+1; jarr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
cout<<“Now the Array after sorting is :n”;
for(i=0; i<size; i++)
{
cout<<arr[i]<<” “;
}
getch();
}