#include<iostream.h>
#include<conio.h>
void main()
{
int c[5]={4,7,9,8,1};
int i,j,k,temp,n;
int min=3;
for(j=0;j<5;j++)
{
for(i=j;i<5;i++)
{
if(c<min)
{
min=c;
}
}
for(k=0;k<5;k++)
{
if(min==c[k])
{
temp=c[k];
c[k]=c[j];
c[j]=temp;
}
}
}
for(n=0;n<5;n++)
cout<<c[n];
getch();
}
//i tried to use this program for arranging elements in ascending order in an array...it does not give the desired output...pls tell me the reason
#include<conio.h>
void main()
{
int c[5]={4,7,9,8,1};
int i,j,k,temp,n;
int min=3;
for(j=0;j<5;j++)
{
for(i=j;i<5;i++)
{
if(c<min)
{
min=c;
}
}
for(k=0;k<5;k++)
{
if(min==c[k])
{
temp=c[k];
c[k]=c[j];
c[j]=temp;
}
}
}
for(n=0;n<5;n++)
cout<<c[n];
getch();
}
//i tried to use this program for arranging elements in ascending order in an array...it does not give the desired output...pls tell me the reason