Bubble sort program in C

Here is the program to sort the given integer in ascending order using bubble sort method. Please find the pictorial tutor of the bubble sorting.

Logic :  The entered integers are stored in the array A. Here, to sort the data in ascending order, any number is compared with the next numbers for orderliness. i.e. first element A[0] is compared with the second  element A[1]. If forth is greater than the prior element then swapping them, else no change. Then second element is compared with third element, and procedure is continued. Hence, after the first iteration of the outer for loop, largest element is placed at the end of the array. In the second iteration, the comparisons are made till the last but one position and now second largest element is placed at the last but one position. The procedure is traced till the array length.

If we complement the if condition in this program, it will give out the sorted array in descending order. Sorting can also be done in other methods, like selection sorting and insertion sorting, which follows in the next pages.

Here is the C program to sort the numbers using Bubble sort

```#include void main() { int A[20], N, Temp, i, j; clrscr(); printf(“\n\n\t ENTER THE NUMBER OF TERMS…: “); scanf(“%d”,&amp;N); printf(“\n\t ENTER THE ELEMENTS OF THE ARRAY…:”); for(i=0; i&lt;N; i++) { scanf(“\n\t\t%d”, &amp;A[i]); } for(i=0; i&lt;N-1; i++) for(j=0; j&lt;N-i;j++) if(A[j]&gt;A[j+1]) { Temp = A[j]; A[j] = A[j+1]; A[j+1] = Temp; } printf(“\n\tTHE ASCENDING ORDER LIST IS…:\n”); for(i=0; i&lt;N; i++) printf(“\n\t\t\t%d”,A[i]); getch(); }```

Start exploring endless computing possibilities with your own Raspberry Pi computer and accessories. Perfect for beginners and students.

76 Responses to “Bubble sort program in C”

1. thanks for uploading program….it helps me in the exam….just copy paste dude….

2. Gold is one of the traditional precious metals used for wedding jewelry.

So how can the happy couple reduce the unrivalled stress levels that come with such an predominant event in their lives.
As a wedding is a one-time event, the photographer must be prepared for the unexpected.

3. The equipment itself is not really particularly expensive these times,
so leasing can cost considerably more in the medium-to-long term.

You can know all the ins and outs of business and can run a restaurant without fail; but would you know the first thing about installing the kitchen grills.
Two: Increase in income – When you are able to increase your
traffic to the business, you will easily be able to also increase

4. Starting a small business with no money may sound impossible but there are ways to kick off a very profitable
You can know all the ins and outs of business and can run a restaurant without fail;
but would you know the first thing about installing the
kitchen grills. Clients do not look no matter whether you’ve a small or big budgeted communication service.

5. The equipment itself is not really particularly expensive these
times, so leasing can cost considerably more in the medium-to-long term.
When job offers do come and I’ll admit, some companies may fear hiring you because they
fear a former owner being an employee, negotiate the best salary you can along with the best benefits you can for
you and your family. What you give away doesn’t have to be costly, but it must be valuable.

6. The equipment itself is not really particularly expensive these times,
so leasing can cost considerably more in the medium-to-long term.
Without enough traffic, you will never have enough
customers and this means you won’t be making enough money.
For clients, you can target neighborhoods, communities
or even companies.

7. The following are the benefits that you have to be aware of
the most. You can know all the ins and outs of business and can run a
restaurant without fail; but would you know the first thing about installing the kitchen grills.
Two: Increase in income – When you are able to increase your traffic to the business, you will easily be able to also

8. If you’re educated (or seeking an education) you will probably find a ton of opportunity in a
small town. As with everything else, it is only the mindset of the entrepreneur that dictates the success
and failure of a company. For clients, you can target neighborhoods,
communities or even companies.

9. Or, perhaps you’re one of those students who desires a challenge, or even a
You can know all the ins and outs of business and can run a restaurant without fail; but
would you know the first thing about installing the kitchen grills.
Typically, this works well if we are involved in a solid networking and we reciprocate, by referring clients to those

10. Yet, there are grants that are made for equipment and
training. You can know all the ins and outs of business and
can run a restaurant without fail; but would you know the first thing about installing the
kitchen grills. Clients do not look no matter whether you’ve a small or big
budgeted communication service.

11. Then send the postcard to all of the addresses in your area, and try to draw customers in.

Platforms: Android, Blackberry, i – Phone, i
– Pad, Windows Phone. For clients, you can target neighborhoods, communities or even companies.

12. Yet, there are grants that are made for equipment and training.
A lot of people have small business ideas that they often fail to put into
practice either because they lack the money to make an investment or because the fear to
lose everything. When travelling, for instance, it would be

13. Or, perhaps you’re one of those students who desires a challenge, or even a good
loan must be need-based, subject to ceiling of Rs 25,000 per borrower for purchase of machinery or equipment etc,
and meeting working capital requirement of one operating cycle.
Two: Increase in income – When you are able to increase your traffic
to the business, you will easily be able to also increase your income.

14. thanks for this
but could you just tell me the difference between insertion and bubble sort.