Friday 20, April 2018
Welcome Guest, Register | Login  
      Home       Tutorials       Free Ebooks       Free Scripts       Tech News       Articles       About Us       Blog        Forum

  Bubble sort using c language

This program will sort an array using bubble sort in c language. c program for bubble sort, bubble sort in c, sorting an array using bubble sort in c language.
Cut & Paste Script
#include <stdio.h>
 
int main()
{
  int array[100], n, c, d, swap;
 
  printf("Enter number of elements\n");
  scanf("%d", &n);
 
  printf("Enter %d integers\n", n);
 
  for (c = 0; c < n; c++)
    scanf("%d", &array[c]);
 
  for (c = 0 ; c < ( n - 1 ); c++)
  {
    for (d = 0 ; d < n - c - 1; d++)
    {
      if (array[d] > array[d+1]) /* For decreasing order use < */
      {
        swap       = array[d];
        array[d]   = array[d+1];
        array[d+1] = swap;
      }
    }
  }
 
  printf("Sorted list in ascending order:\n");
 
  for ( c = 0 ; c < n ; c++ )
     printf("%d\n", array[c]);
 
  return 0;
}
   
     RELATED SCRIPTS
 
C program to join two strings without using strcat
This c language program will join two strings without using strcat string function....more »
Category : C Programs Hits : 2258
   
Compare two strings using c
This program will input two strings and compare them. It will show both strings are equal, first string is greater than second or first string is less than second....more »
Category : C Programs Hits : 1700
   
Find Factorials using Recursion in c
This c program will use recursive function and calculate the factorial of given number....more »
Category : C Programs Hits : 1828
   
pointer and there uses in c
Example code for pointer and there uses in c language....more »
Category : C Programs Hits : 1972
   
concatenate two strings c language
Here is an example code to concatenate two strings using clanguage....more »
Category : C Programs Hits : 3332
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download The Magic Bullet  Ebook The Magic Bullet
   
Download Structure and Interpretation of Computer Programs  Ebook Structure and Interpretation of Computer Programs
   
Download EMarketing In A Box  New Updated 2008 Edition Ebook EMarketing In A Box New Updated 2008 Edition
   
Download Turning One Into A Million Ebook Turning One Into A Million
   
Download Make A Living Off Your Blog Ebook Make A Living Off Your Blog
   
Studiesinn.com 2018 All Rights Reserved.