Write a c program that implements the bubble sort method to sort a given list of integers in ascending order
Answers
Answered by
1
1. Create an array of fixed size (maximum capacity), lets say 10.
2. Take n, a variable which stores the number of elements of the array, less than maximum capacity of array.
3. Iterate via for loop to take array elements as input, and print them.
4. The array elements are in unsorted fashion, to sort them, make a nested loop.
5. In the nested loop, the each element will be compared to all the elements below it.
6. In case the element is greater than the element present below it, then they are interchanged
7. After executing the nested loop, we will obtain an array in ascending order arranged elements.
Similar questions
Biology,
6 months ago
Geography,
6 months ago
Math,
6 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Environmental Sciences,
1 year ago
Environmental Sciences,
1 year ago