#include<iostream>
using namespace std;
int main()
{
int size,i,j,position,temp;
cout<<"Enter the size of array:-\t";
cin>>size;
int array[size];
for(i=0;i<size;i++)
cin>>array[i];
cout<<"Enter the index number from where you want to sort array in ascending order:-\n";
cin>>position;
for(i=position-1;i<size;i++)
for(j=position;j<size;j++)
if(array[i]<array[j])
{
temp=array[i];
array[i]=array[j];
array[j]=temp;
}
cout<<"New sorted array is :-\n";
for(i=0;i<size;i++)
cout<<array[i]<<" ";
}
Comments
Post a Comment