Bubble sort c program, C/C++ Programming

Assignment Help:

Bubble sort C program:

Write a program to define a bubble sort.

void main()

 {

  clrscr();

  int a[100],ch,n;

  cout<<"enter the limit for the array : ";

  cin>>n;

  for (int i=0;i

                {

                cout<<"enter element "<

                cin>>a[i];

                }

                clrscr();

                cout<<"1. bubble sorting"<

                bsort(a,n);

                 }

 }

 

void bsort(int a[100],int n)

 {

   clrscr();

   int i,j,ch2,t;

   cout<<"1. ascending order "<

   cout<<"2. descending order "<

   cout<<" your choice : ";

   cin>>ch2;

   switch(ch2)

                {

                case 1 : for (i=0;i

                                                 {

                                 for (j=0;j

                                                {

                                                if (a[j] > a[j+1])

                                                {

                                                t=a[j+1];

                                                a[j+1]=a[j];

                                                a[j]=t;

                                                }

                                                }

                                 }

                                 break;

                case 2 : for (i=0;i

                                 {

                                 for (j=0;j

                                                {

                                                if (a[j] < a[j+1])

                                                {

                                                t=a[j+1];

                                                a[j+1]=a[j];

                                                a[j]=t;

                                                }

                                                }

                                 }

                                 break;

   default : cout<<" wrong choice ";

                }

                 cout<<" sorted arrays by bubble "<<"\n\n";

                 for (i=0;i

                  {

                  cout<

                  }

                  getch();

 

  }


Related Discussions:- Bubble sort c program

Define the arithmetic operators in c language, Define the Arithmetic Operat...

Define the Arithmetic Operators in c Language? There are five arithmetic operators in C and they are Operator             Purpose +                        Addition -

Identifier and constant, What are  Id e n t i f ie rs a n d C o...

What are  Id e n t i f ie rs a n d C o n s t a n ts in C++? Id e n t i f ie r a n d C o n s t a n t : I d e n t i f ie r

Flowcharting, how to create a flowchart? can you help me in my assignment a...

how to create a flowchart? can you help me in my assignment about flowcharting ....

develop a calculator in masm, Part 1 Assignment:  develop a calculator...

Part 1 Assignment:  develop a calculator in MASM. Text chapters covered:  1 through 4, 5.4, 5.5, 6.3, 7.4 You will develop a "calculator" algorithm in MASM using reverse-

Develop a biomedical imaging project, Develop a biomedical imaging project ...

Develop a biomedical imaging project Project Description: This is a biomedical imaging project. Skills required are C++ Programming, Cocoa, Mac OS, Objective C

C/c++, Byteland county is very famous for luminous jewels. Luminous jewels ...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Bitwise operations, Bitwise Operations 1. Write a function that has an ...

Bitwise Operations 1. Write a function that has an int parameter n, makes an integer mask having the bit 1 at the nth place from the rightmost bit, and returns the mask. For ex

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd