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

Program that computes square matrix multiplication, Goal: Design a progr...

Goal: Design a program that computes square matrix multiplication on GPU using CUDA. Write the code in C. In particular, your implementation should obey the following requiremen

Sort wars, Explain each of the algorithms in a way that would be understand...

Explain each of the algorithms in a way that would be understandable to an intelligent person who is not familiar with programming. You should not use any code (or even pseudo code

Why are all header files not declared in every c program, Why are all heade...

Why are all header files not declared in every C program? - Declaring all header files in each program would result in increase in overall file size and load of the program. It

Functions, Define  F u n c t i o n?  T h e r e a r e t...

Define  F u n c t i o n?  T h e r e a r e t w o t y p e s o f f u n ct i o n b u i l t - i n f un ct i o n s a n d u

Operation on array - c program, Operation on array: void Array::add( O...

Operation on array: void Array::add( Object& toAdd ) {     lastElementIndex++;     while( ptrAt( lastElementIndex ) != ZERO &&            lastElementIndex

#title., A student apears in exam of math, physics, and chemistry. Write a...

A student apears in exam of math, physics, and chemistry. Write a program to find the total marks aa student has aqueired find the average.

Program is to define a class as employee, Program is to define a class as e...

Program is to define a class as employee: Write a program to define a class as employee and collect information about them by using classes and object class employee   {

PROGRAMMING, PROCEDUAL PROGRAMMING INTRODUCTION

PROCEDUAL PROGRAMMING INTRODUCTION

Determine the capacitor voltage by c program, Write a program to determine ...

Write a program to determine V c for a given value of time (t)   #include stdio.h #include math.h void main() {      char prompt;   float vs,cr,t,vc;   /* input time */

Integer parameters, write a static method with one integer parameter, x tha...

write a static method with one integer parameter, x that returns the value of the polynomial 3x(2)- 7x + 2

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