#include <stdio.h>
int main() {
int a[100], i, j, n, t;
printf("Enter size of the array\n");
scanf("%d", & n);
printf("Enter Elements into the array\n");
for (i = 1; i <= n; i++) {
scanf("%d", & a[i]);
}
for (i = 1; i <= n - 1; i++) {
for (j = 1; j <= n - i; j++)
{
if (a[j] > a[j + 1]) {
t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
printf("The Sorted Array is :\n");
for (i = 1; i <= n; i++)
{
printf("%d\n", a[i]);
}
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter size of the array
4
Enter Elements into the array
4
7
3
8
The Sorted Array is :
3
4
7
8