C LANGUAGE subject (JNTU-H Syllabus)Download free c software...etc
Pages
Home
Easy way to EARN MONEY from HOME
MBA
BTECH English(JNTUH)
MOBILES
JNTU WORLD
SPICY FOOD (RECIPES)
clanguage07@gmail.com
Sunday, September 8, 2013
BUBBLE SORT USING C PROGRAM
Source code of simple bubble sort implementation using array ascending order in c programming language
#include
<stdio.h>
int
main(){
int
s,temp,i,j,a[20];
printf(
"Enter total numbers of elements: "
);
scanf(
"%d"
,&s);
printf(
"Enter %d elements: "
,s);
for
(i=0;i<s;i++)
scanf(
"%d"
,&a[i]);
//Bubble sorting algorithm
for
(i=s-2;i>=0;i--){
for
(j=0;j<=i;j++){
if
(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf(
"After sorting: "
);
for
(i=0;i<s;i++)
printf(
" %d"
,a[i]);
return
0;
}
Output:
Enter total numbers of elements: 5
Enter 5 elements: 6 2 0 11 9
After sorting: 0 2 6 9 11
1. Write a c program for bubble sort.
2. Write a c program for insertion sort.
3. Write a c program for selection sort.
4. Write a c program for quick sort.
5. Write a c program for heap sort.
6. Write a c program for merge sort.
7. Write a c program for shell sort.
8. Big list of c program examples
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
GET MORE INFORMATION
http://ads.qadservice.com/t?id=c2168e05-8974-4816-872a-91936ff7379d&size=1024x768&drct=true
No comments:
Post a Comment