int main()
{
int a[100],n,k,i,j,temp;
printf("How many elements\n");
scanf("%d",&n);
printf("Enter the element of array");
for(i=0;i<=n-1;i++)
{
scanf("%d",&a[i]);
}
for(k=1;k<=n-1;k++) { temp=a[k]; j=k-1; while((temp=0))
{
a[j+1]=a[j];
j=j-1;
}
a[j+1]=temp;
}
printf("Element of array after sorting\n"); /*statement to be displayed*/
for(i=0;i<=n-1;i++)
{
printf("%d\n",a[i]);
}
return 0;
}
OUTPUT
How many elements
3
Enter the element of array
1
7
4
Element of array after sorting
1
4
7
No comments:
Post a Comment