#include <stdio.h>
int main() {
int arr[5];
for(int i = 0; i < 5; i++) {
if(scanf("%d", &arr[i]) != 1) {
printf("Failed to get input.\n");
return 1;
}
}
for(int i = 0; i < 5; i++) {
for(int j = 0; j < 4; j++) {
if(arr[j+1] < arr[j]) {
int tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
}
}
for(int i = 0; i < 5; i++) {
printf("%d ", arr[i]);
}
return 0;
}
#if 0
int main() {
int a[10];
int n;
printf("enter the no of digits :- ");
scanf("%d\n",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int x=1;x<n;x++){// sorts 0-4 and send to y
for(int y=0;y<n-x;y++){// sort 0-3,0-2,0-1,0
//if(a[y]<a[y+1])//reverse sort
if(a[y]>a[y+1]){//sort and if bigger sends last and store then reduce one step
int temp = a[y];
a[y]=a[y+1];
a[y+1]=temp;
}
}
}
for(int i=0;i<n;i++){
printf("%d",a[i]);
}
}
#endif
To embed this program on your website, copy the following code and paste it into your website's HTML: