Sort array in ascending order using user defined function in c language

preview_player
Показать описание
Sort array in ascending order using user defined function in c language

How to sort array in ascending order using user defined function in c language

Code of the program is in the comment box
Рекомендации по теме
Комментарии
Автор

#include<stdio.h>
void ascending(int a[], int e){
int t, i, j;
for(i=0;i<e;i++){
for(j=i+1;j<e;j++){
if(a[i]>a[j]){
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
}
void main(){
int a[30], i, s;
printf("Enter the size of array :");
scanf("%d", &s);
printf("Enter the value of array :");
for(i=0;i<s;i++)
scanf("%d", &a[i]);
ascending(a, s);
printf("Array in ascending order :");
for(i=0;i<s;i++)
printf("%d ", a[i]);
}

uniquecoding