Bubble sort in c explain the code | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
- 1

Bubble sort in c explain the code

#include <stdio.h> int main() { int total_count, counter, counter1, swap_var; int array[20]; printf("How many number you want to input?\n"); scanf("%d", &total_count); printf("Please enter %d integers that has to be sorted\n", total_count); for (counter = 0; counter < total_count; counter++) scanf("%d", &array[counter]); for (counter = 0 ; counter < total_count - 1; counter++) { for (counter1 = 0 ; counter1 < total_count - counter - 1; counter1++) { if (array[counter1] > array[counter1+1]) /* For decreasing order use < */ { swap_var        = array[counter1]; array[counter1]   = array[counter1+1]; array[counter1+1] = swap_var; } } } printf("Below is the list of elements sorted in ascending order:\n"); for (counter = 0; counter < total_count; counter++) printf("%d\n", array[counter]); return 0; }

6th Sep 2022, 6:57 AM
Abhishek
Abhishek - avatar
1 ответ
+ 4
abhishek bairwa Explanation is here.. then try to understand code. if anything is not understand then you can ask about that specific piece of code.. with mentioning how much you understood ...!!! hope it helps.. https://www.sololearn.com/learn/649/?ref=app
6th Sep 2022, 7:36 AM
Jayakrishna 🇮🇳