• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Bubble Sort Code in C Language

July 6, 2013 by ProjectsGeek 1 Comment

Bubble Sort Code in C Language

Write a program in C to sort n integers using bubble sort. Program should ask for number of Elements for sorting and then user need to enter numbers. At the end program should process these numbers and print the result.

Bubble Sort code should have options for both ..

  • Ascending Order sorting
  • Descending Order Sorting

Bubble sort is the most basic and simple algorithm for sorting.It uses loop for sorting numbers,As the number to be sorted increases time to sort also increases.

Algorithm Bubble Sort

Bubble Sort Code in C

Bubble Sort Code

#include <stdio.h>
#include<conio.h>

void main()
{
int array[100], n, i, j, swap;
clrscr();

printf(“Enter number of elements\n”);
scanf(“%d”, &n);

printf(“Enter %d integers\n”, n);

for (i = 0; i < n; i++)
scanf(“%d”, &array[i]);

for (i = 0 ; i < n – 1 ; i++)
{
for (j = 0 ; j < n – i – 1; j++)
{
if (array[j] > array[j+1]) /* For decreasing order use < */
{
swap = array[j];
array[j] = array[j+1];
array[j+1] = swap;
}
}
}

printf(“Sorted list in ascending order:\n”);

for ( i = 0 ; i < n ; i++ )
printf(“%d\n”, array[i]);

getch();
}

 

Other Projects to Try:

  1. Quick sort using recursion
  2. Display Numbers in Ascending Order C language
  3. Mobile User Information Project
  4. Assembly Language Codes
  5. Prims algorithm Code in C Language

Filed Under: Uncategorized

Reader Interactions

Comments

  1. Vishal says

    February 9, 2015 at 3:04 pm

    thanks. it was helpful.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy