#include<iostream>
using namespace std;
int main()
{
int a[5]={3,2,5,7,8},tem;
// show value of array before sorting
for(int i=0;i<5;i++)
{
cout<<"Value of array:"<<a[i]<<endl;
}
for(int i=0;i<5;i++)
{
for(int j=0;j<4-i;j++)
{
if(a[j]>a[j+1])
{
tem=a[j+1];
a[j+1]=a[j];
a[j]=tem;
}
}
}
// Show output of sorting array
for(int i=0;i<5;i++)
{
cout<<"Value of array :"<<a[i]<<endl;
}
return 0;
}
No comments:
Post a Comment