Computer Science, asked by sahaarpita726, 2 months ago

Write A Program Input 10 integer elements in an array and sort them in Ascending order using the bubble short Technique​

Answers

Answered by shahzadiasra123
0

Explanation:

// Bubble short

#include <stdio.h>

int main() {

int array[50], n, i, j, swap;

printf("\n Enter number of elements\n");

scanf("%d", &n);

printf("\n 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]) /* For decreasing order use < */

{

swap = array[j];

array[j] = array[j + 1];

array[j + 1] = swap;

}

}

}

printf("Sorted list in ascending order:\n");

for (i = 0; i < n; i++)

{

printf("%d\n", array[i]);

}

return 0;

}

Similar questions