#include <stdio.h>
#include <conio.h>
int main()
{
int myarray[50]; int i, j, n, temp;
/* Get number of elements in the array */
printf("Enter number of elements in the array \n");
scanf("%d", &n);
/* Read elements of the array */
printf("Enter the array elements \n");
for (i = 0; i < n; i++)
scanf("%d", &myarray[i]);
/* Sort elements of the array */
for (i = 1; i < n; i++)
{
j = i; while ( (j > 0) && (myarray[j-1] > myarray[j]) )
{
temp = myarray[j-1];
myarray[j-1] = myarray[j];
myarray[j] = temp; j--;
}
}
/* Print the sorted array */
printf("Sorted Array\n");
for (i = 0; i < n; i++)
printf("%d \n", myarray[i]);
getch();
return 0;
}
/