Ascending And Descending Order

in Hindi - Ascending And Descending Order



not yet

Source Code :

RUN#include <stdio.h>

int main(){

int num, arr[10], i, j, temp;

printf("Enter size of array : \n");
scanf("%d",&num);

printf("Enter %d element\n", num);
for(i=0; i<num; i++){
 scanf("%d", &arr[i]);
}

for(i=0; i<num-1; i++){
for(j=i+1; j<num; j++){
if(arr[i] > arr[j]){
    temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
}
}
}
printf("Ascending Sorting :\n");
for(i=0; i<num; i++){
    printf("%d\n", arr[i]);
}

for(i=0; i<num-1; i++){
for(j=i+1; j<num; j++){
if(arr[i] < arr[j]){
    temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
}
}
}
printf("Descending Sorting :\n");
for(i=0; i<num; i++){
    printf("%d\n", arr[i]);
}

return 0;
}