Tuesday 23, May 2017
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    About Us    |    Contact Us

  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 : 2033
   
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 : 1473
   
Convert decimal number to binary number in c
This c language program will input an integer in decimal numbers system and convert it to binary numbers system. Decimal to Binary Conversion, Convert from decimal to binary using c language....more »
Category : C Programs Hits : 4123
   
Check the given year is leap or not using c
This program will input a year and check whether it is a leap year or not....more »
Category : C Programs Hits : 3078
   
C program to show memory address of array elements and access array elements using pointers
This program will visualize the memory address of each array element and will show you how to access array elements using pointer....more »
Category : C Programs Hits : 2948
   
   
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 Video Marketing Tactics Using Ebook Video Marketing Tactics Using
   
Download SEO Made Easy Ebook SEO Made Easy
   
Download Introduction to Object-Oriented Programming Using C++  Ebook Introduction to Object-Oriented Programming Using C++
   
Download Affiliate Marketing Mistakes & How To Make Sure You Avoid Them  Ebook Affiliate Marketing Mistakes & How To Make Sure You Avoid Them
   
Download Algorithmic Problem Solving Ebook Algorithmic Problem Solving
   
     
Studiesinn.com 2017 All Rights Reserved.
 
Website Designed & Developed by TechXprtz