#include
#include
int main()
{
int a[100],i=0,l,j,t;
printf(" enter a list of positive integers to be sorted enter negative no. to exit \n ");
do
{
scanf("%i",&a[i]);
i=i+1;
}
while(a[i-1]>=0);
l=i-2;
printf("the values you have entered are");
for(i=0;i{printf("the values you have entered are \n %i",a[i]);
}
for(i=l;i>0;i--)
{
for(j=0;j {
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
printf("sorted array is:\n");
for(i=0;i<=l;i=i+1) printf("%d \n",a[i]);
getch();
return 0;
}
No comments:
Post a Comment