//This is a program of sorting the given array
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[5],temp,i,j;
//Accepting the array elements
cout<<"\n\n\tEnter the elements of the array: ";
for(i=0;i<5;i++)
{
cout<<"\n\tEnter the element: ";
cin>>a[i];
}
//Displaying the array elements
cout<<"\n\n\tDisplaying the array elements before sorting: \n\t";
for(i=0;i<5;i++)
cout<<" "<<a[i];
//Sorting the array elements
for(i=0;i<4;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
//Displaying the sorted array
cout<<"\n\n\tDisplaying the array elements after sorting: \n\t";
for(i=0;i<5;i++)
cout<<" "<<a[i];
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[5],temp,i,j;
//Accepting the array elements
cout<<"\n\n\tEnter the elements of the array: ";
for(i=0;i<5;i++)
{
cout<<"\n\tEnter the element: ";
cin>>a[i];
}
//Displaying the array elements
cout<<"\n\n\tDisplaying the array elements before sorting: \n\t";
for(i=0;i<5;i++)
cout<<" "<<a[i];
//Sorting the array elements
for(i=0;i<4;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
//Displaying the sorted array
cout<<"\n\n\tDisplaying the array elements after sorting: \n\t";
for(i=0;i<5;i++)
cout<<" "<<a[i];
return 0;
}