#include
using namespace std;
int selection_sort(int arr[],int n)
{
for(int i=0;i<n-1;i++)
{
int min_index=i;
for(int j=i;j<=n;j++)
{
if(arr[j]<arr[min_index])
{
min_index=j;
}
}
swap(arr[i],arr[min_index]);
}
}
int main()
{
int n;
cout<<"enter the size of array: ";
cin>>n;
int arr[n];
cout<<"enter the elemnts of array: ";
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
selection_sort(arr,n);
cout<<printarray(arr,n);
}
only the second largest element of the array is printing how can we print the whole sorted array.