Bubble Kind Code in C Language
Write a program in C to kind n integers utilizing bubble kind. Program ought to ask for variety of Parts for sorting after which person must enter numbers. On the finish program ought to course of these numbers and print the end result.
Bubble Kind code ought to have choices for each ..
- Ascending Order sorting
- Descending Order Sorting
Bubble kind is essentially the most primary and easy algorithm for sorting.It makes use of loop for sorting numbers,Because the quantity to be sorted will increase time to kind additionally will increase.
Algorithm Bubble Kind
Bubble Kind Code
1 |
#embody <stdio.h><br/>#embody<conio.h><br/><br/>void predominant()<br/>{<br/>int array[100], n, i, j, swap;<br/>clrscr();<br/><br/>printf(“Enter variety of elementsn”);<br/>scanf(“%d”, &n);<br/><br/>printf(“Enter %d integersn”, n);<br/><br/>for (i = 0; i < n; i++)<br/>scanf(“%d”, &array[i]);<br/><br/>for (i = 0 ; i < n – 1 ; i++)<br/>{<br/>for (j = 0 ; j < n – i – 1; j++)<br/>{<br/>if (array[j] > array[j+1]) /* For reducing order use < */<br/>{<br/>swap = array[j];<br/>array[j] = array[j+1];<br/>array[j+1] = swap;<br/>}<br/>}<br/>}<br/><br/>printf(“Sorted checklist in ascending order:n”);<br/><br/>for ( i = 0 ; i < n ; i++ )<br/>printf(“%dn”, array[i]);<br/><br/>getch();<br/>} |
Supply projectgeek.com