int main()
{
int i,j,num,list[6],temp;
printf("Enter the Numbers:");
for(i=0;i<6;i++)
{
scanf("%d",&list[i]);
}
printf("Entered Numbers are:");
for(i=0;i<6;i++)
{
printf("%d ",list[i]);
}
for(i=0;i<6;i++)
{
for(j=0;j<5;j++)
{
if(list[j]>list[j+1])
//if u change > as < you will get Descending order
{
temp=list[j];
list[j]=list[j+1];
list[j+1]=temp;
}
}
}
printf("\nascending order\n");
for(j=0;j<6;j++)
{
printf("%d ",list[j]);
}
printf("\n");
}
No comments:
Post a Comment