Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # Program for Bubble Sort elements in Ascending Order

• 0
• 0
• 0
• 0
• 0
• 0
• 1
• 0
• 530
Comment on it

Program for Bubble Sort elements in Ascending Order

Definition:- In Bubble sort each element compares with the other elements until finds its correct order place. This is repeated until all elements are in the order.

```//Header Files
#include<stdio.h>
#include<conio.h>

void main()
{
int n, i, j, k, flag, limit, arr[20]; //Variables
clrscr();            //to clear screen
// User to input the limit of the array
printf("\n Enter the limit:-");
scanf("%d",&n);                // To scan the limit of the array
//Asking user to input the elements of the array
printf("\n Enter the element of Array to sort:->\n");
for(i=0;i<n;i++)
scanf("%d", &arr[i]);  //Scanning the elements in the array
limit=n-1;          // Setting the limit to execute the array
flag =1;
for(i=0; i<n;i++)
{
for(j=0;j<limit-i;j++)
{
if(arr[j]>arr[j+1])   //Comparing array elements
{                    //Swapping the elements
k=arr[j];
arr[j]= arr[j+1];
arr[j+1]=k;
flag=0;
}
}

if (flag==1)
break;
else
flag=1;
}
printf("\n Element in ascending order with Bubble sort are:-");
for(i=0;i<n;i++)
{
printf("\n%d",arr[i]);  //Printing the Sorted array
}
getch();
}
```

Output:-

```Enter the limit:-5

Enter the element of Array to sort:->
9
7
4
6
0

Element in ascending order with Bubble sort are:-
0
4
6
7
9
```

## 0 Comment(s)

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...