0% found this document useful (0 votes)
63 views2 pages

C Program For Bubble Sort

This document contains a C program that implements bubble sort to sort an array of integers in ascending order. The program takes input of total numbers and elements of the array, performs bubble sort on the array by swapping adjacent elements if they are out of order, and prints the sorted array as output. Bubble sort works by repeatedly stepping through the list, compares adjacent elements and swaps them if they are in the wrong order.

Uploaded by

OmPrakashKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views2 pages

C Program For Bubble Sort

This document contains a C program that implements bubble sort to sort an array of integers in ascending order. The program takes input of total numbers and elements of the array, performs bubble sort on the array by swapping adjacent elements if they are out of order, and prints the sorted array as output. Bubble sort works by repeatedly stepping through the list, compares adjacent elements and swaps them if they are in the wrong order.

Uploaded by

OmPrakashKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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: [email protected]
Engineer(Final Year)
Phone: 9762333747
Vishwakarma Institute Of
Url: http://www.vitedu.in/ RSS Sharing
Technology, Pune
Upper Indiranagar, Mahesh
Email: [email protected]
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