KALYAN CITY LIFE

Sharing Wisdom and Vivid Memories of Life

About

Kalyan City is a fast emerging residential township in the Thane district of Maharashtra state, India. It is a central suburban town and resides 54 kms north-east of Mumbai. This blog regularly shares quality academic materials. Here we also document our unique experiences and vivid memories of life. Read our lucid informative articles to excel your understanding, knowledge and success.

Team

Articles published on Kalyan City Life blog are inspired from our work experience, field research, study of various good books and papers, seminars and consultations from subject scholars. Our unique collection of useful study notes is an outcome of a team effort and hard work of Gaurav Akrani, Prof. Mudit Katyani and Manoj Patil.

yin yang

Bubble Sorting C Program Bubble Sort - C Programming



square Write A C Program To Implement Bubble Sorting


Once again I started practicing and learning C Programming Language. Yesterday I was working on Sorting Techniques. I wrote following C Program to implement Bubble Sort Technique and used Borland Turbo C compiler. Feels great to share it on the internet. Interested students can try compiling and modifying following C Program on their Borland Turbo C Compiler.


C Program Bubble Sorting























square C Program - Implementing Bubble Sort Technique


//Analysis of Algorithms
//Sorting Techniques - C Data Structures
//WACP  to Iimplement Bubble Sort Technique.
//Program by:- GAURAV AKRANI. 
//TESTED:- OK


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

  void bubble(int a[],int n)
  {
        int i,j,t;
         for(i=n-2;i>=0;i--)
         {
            for(j=0;j<=i;j++)

                  {
                    if(a[j]>a[j+1])
                                    {
                                      t=a[j];
                                     a[j]=a[j+1];
                                     a[j+1]=t;
                                    }
                   }
       

           }//end for 1.

  }//end function.


  void main()
  {

      int a[100],n,i;

      clrscr();

      printf("\n\n Enter integer value for total no.s of elements to be sorted: ");
      scanf("%d",&n);

      for( i=0;i<=n-1;i++)
            { printf("\n\n Enter integer value for element no.%d : ",i+1);
              scanf("%d",&a[i]);
            }

       bubble(a,n);

       printf("\n\n Finally sorted array is: ");
       for( i=0;i<=n-1;i++)
       printf("%3d",a[i]);

  } //end program.

/*

--------SAMPLE OUTPUT----------------------


Enter integer value for total no.s of elements to be sorted: 6


Enter integer value for element no.1 : 89


Enter integer value for element no.2 : -4


Enter integer value for element no.3 : -67


Enter integer value for element no.4 : 5


Enter integer value for element no.5 : 78


Enter integer value for element no.6 : 11


Finally sorted array is: -67 -4 5 11 78 89

------------------------------------------

*/





squareRelated



squareTranslation



FlagsFrance flagGermany flagItaly flagBrazil flagSpain flagJapan flagIndia flagChina flagRussia flagdefault

1 Comment :

  1. Anonymous said...

    Thank You its working good

Please Comment



 
Scroll Top