#include<stdio.h>
#include<conio.h>
void main()
{
int array[25], num, i, j, temp;
clrscr();
printf ("Please Enter the maximum elements\n");
scanf ("%d",&num);
printf ("Please Enter the elements to be sort:\n");
for (i = 0; i < num; i++)
scanf ("%d", &array[i]);
for (j = 0; j < num - 1; j++){
temp = array[0];
for (i = 1; i < num; i++){
if (array[i] < temp){
array[i - 1] = array[i];
array[i] = temp;
}
else
temp = array[i];
}
}
printf ("Sorted Elements are:\n");
for (i = 0; i < num; i++)
printf("%d\n", array[i]);
}
No comments:
Post a Comment