Write a 'C' program to accept names from the
user and sort in alphabetical order using bubble
sort
Answers
Answered by
0
Answer:
I hope you understand friend
Attachments:
Answered by
0
ANSWER:
#include<stdio,h> #include<stdio.h>
int main(){
int array[50], n, i, j, temp;
printf("Enter number of elements\n");
scanf("%d", &n);
printf("Enter %d integers\n", n);
for(i = 0; i < n; i++)
scanf("%d", &array[i]);
for (i = 0 ; i < ( n - 1 ); i++){
for (j= 0 ; j < n - i - 1; j++){
if(array[j] < array[j+1]){
temp=array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
printf("Sorted list in descending order:\n");
for ( i = 0 ; i < n ; i++ )
printf("%d\n", array[i]);
return 0;
}
Similar questions