1#include<stdio.h>
2 #include<stdlib.h>
3
4 int main()
5 {
6 int *a,i=0,j=0,k,l,m,b,least;
7 a=(int *)malloc(sizeof(int));
8
9 while(1)
10 {
11
12 printf(“\n\nenter the elements in an array, remember at ’0′ insertion of elements in array will be terminated : \n”);
13
14 while(1)
15 {
16 scanf(“%d”,a+j);
17 if(a[j]==0)
18 break;
19 a=realloc(a,i+2*sizeof(int));
20 i=i+sizeof(int);
21 j++;
22 }
23
24
25 for(k=0;k<=j;k++)
26 {
27 for(l=k;l<=j;l++)
28 {
29 least=a[k];
30
31 if(least>a[l])
32 {
33 b=a[l];
34 m=least;
35 a[k]=b;
36 a[l]=m;
37
38 }
39 }
40 }
41
42
43 printf(“\n\nthe array in accending order is : \n”);
44
45 for(k=0;k<=j;k++)
46 printf(“%d\n”,a[k]);
47
48 }
49 return 0;
50 }