#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int array[5];
int p[5],i,j;
cout<<"Enter any five numbers: "<<endl;
for(i=0;i<=4;i++)
{
cin>>array[i];
p[i]=array[i];
}
int temp;
cout<<endl<<"After sorting"<<endl<<endl;
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if (p[i]>p[j])
{
temp= p[i];
p[i]= p[j];
p[j]= temp;
}
}
}
for(i=0;i<=4;i++)
{
cout<<p[i]<<" ";
}
getche();
}
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int array[5];
int p[5],i,j;
cout<<"Enter any five numbers: "<<endl;
for(i=0;i<=4;i++)
{
cin>>array[i];
p[i]=array[i];
}
int temp;
cout<<endl<<"After sorting"<<endl<<endl;
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if (p[i]>p[j])
{
temp= p[i];
p[i]= p[j];
p[j]= temp;
}
}
}
for(i=0;i<=4;i++)
{
cout<<p[i]<<" ";
}
getche();
}
No comments:
Post a Comment