You are on page 1of 2

C Program For Bubble Sort Page 1 of 2

Home
Projects
Mini Projects
Embedded Systems
IEEE 2013
IEEE 2012
Electrical Engineering
GSM And GPS Based
Image Processing And Communication
Robotics
VLSI
Mechanical
Programming
C
Data Structure
PDF Books
Engineering Physics
Engineering Chemistry
Share
Engineering Mathematics
Engineering Mechanics
Electrical Technology
Computer Programming
Electronics Engineering
System Verilog
Aptitude Tests
Cognizant
Wipro
Video Tutorials
C Programming
VIT Pune
Syllabus
First year Engineering
Electronics And Telecommunication
Electronics Engineering
Computer Engineering
IT Engineering
Mechanical Engineering
Industrial Engineering
Production Engineering
Instrumentation Engineering
Chemical Engineering
Notice Board
Electronics Department
Second Year
Third Year
Final Year
Coupons
Job Alerts

C Program For Bubble Sort


INPUT

Code:
1.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++){

http://www.vitedu.in/Program/DS/Sorting/bubble%20sort.html 21/11/2014
C Program For Bubble Sort Page 2 of 2

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
Share
After sorting: 0 2 6 9 11

Previous Program
Next Program
Send us a PROGRAM that you do not find here!! Click Here To DOWNLOAD This Program In Text Format

You need to accept third-party cookies in your browser in order to comment using this social plugin.

Add a comment...

Comment using...

Facebook social plugin

About Me Contact Me Follow Us Download Our Toolbar

Ajit Mulik
VitEdu : A Place To Learn
Electronics And Telecommunication
Email: admin@vitedu.in
Engineer(Final Year)
Phone: 9762333747
Vishwakarma Institute Of
Url: http://www.vitedu.in/ RSS Sharing
Technology, Pune
Upper Indiranagar, Mahesh
Email: ajitgappd@gmail.com
Society,Rajlaxmi Heights, Pune - 37
Pune, Maharashatra 411037 Subscribe us by Email
India

http://www.vitedu.in/Program/DS/Sorting/bubble%20sort.html 21/11/2014

You might also like