#include<iostream>
using std::cin;
using std::cout;
#include<conio.h>
void main()
{
int *p,n,a[100],i,*j,t;
cout<<"enter the no of elements: ";
cin>>n;
cout<<"\nenter the elements-\n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(p=&a[0];p<=&a[n-1];p++)
{
for(j=&a[0];j<=&a[n-1];j++)
{
if(*p>*j)
{
t=*p;
*p=*j;
*j=t;
}
}
}
cout<<"\nthe sorted elements are: ";
for(p=&a[0];p<=&a[n-1];p++)
{
cout<<*p<<" ";
}
getch();
}
No comments:
Post a Comment