Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6fc5925

Browse files
Add files via upload
1 parent cfbd566 commit 6fc5925

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎Implementing bubble sort algorithm.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include<stdio.h>
2+
int main()
3+
{
4+
int count,temp,i,j,number[30];
5+
printf("How many numbers?: ");
6+
scanf("%d",&count);
7+
printf("Enter %d numbers: ",count);
8+
9+
for(i=0;i<count;i++)
10+
scanf("%d",&number[i]);
11+
for(i=count-2;i>=0;i--)
12+
{
13+
for(j=0;j<=i;j++)
14+
{
15+
if(number[j]>number[j+1])
16+
{
17+
temp=number[j];
18+
number[j]=number[j+1];
19+
number[j+1]=temp;
20+
}
21+
}
22+
}
23+
printf("Sorted elements: ");
24+
for(i=0;i<count;i++)
25+
printf(" %d",number[i]);
26+
return 0;
27+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /