Bubble Sort in C

Here you will learn about program for bubble sort in C.

Bubble sort is a simple sorting algorithm in which each element is compared with adjacent element and swapped if their position is incorrect. It is named as bubble sort because same as like bubbles the lighter elements come up and heavier elements settle down.

Both worst case and average case complexity is O (n2).

Bubble Sort in C



Enter the size of array: 4
Enter the array elements: 3 7 9 2

Array after sorting: 2 3 7 9


Comment below if you have any doubts related to above program for bubble sort in C.

7 thoughts on “Bubble Sort in C

  1. Ajay shankhwar

    Why we use return 0 ?
    If we will not use it.what changes may occur in program?

    1. Tushar shende

      We have write the written type of main as “int” so at last it should write something value ,,,so the return 0 is written.

      If u use written type of main as “void main” then “getch()” will work fine


Leave a Reply

Your email address will not be published. Required fields are marked *