We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b3bcb3 commit c661f05Copy full SHA for c661f05
BubbleSort.c
@@ -0,0 +1,35 @@
1
+#include<stdio.h>
2
+void main()
3
+{
4
+ int i,j,no,c,temp;
5
+ printf(" Enter The Size of 1D Array\n");
6
+ scanf(" %d", &no);
7
+ int arr[no];
8
+ printf(" Enter The Elements into the Array: \n");
9
+ for(i=0;i<no;i++)
10
+ scanf("%d",&arr[i]);
11
+ printf("\n\n The Given Array Is:\n \n");
12
13
+ printf("%d ",arr[i]);
14
+ /*BUBBLE SORT*/
15
+ printf("\n\n The Sorted Array Is: \n\n");
16
+ for(j=0;j<no;j++)
17
+ {
18
+ for(i=(no-1);i>c;i--)
19
20
+ if(arr[i]<arr[i-1])
21
22
+ temp=arr[i-1];
23
+ arr[i-1]=arr[i];
24
+ arr[i]=temp;
25
+ }
26
+ else
27
+ continue;
28
29
+ ++c;
30
31
32
+ printf("%d ", arr[i]);
33
+ printf("\n");
34
+}
35
+
0 commit comments