Bubble sort c program, C/C++ Programming

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();

 

  }

Posted Date: 10/19/2012 3:11:09 AM | Location : United States







Related Discussions:- Bubble sort c program, Assignment Help, Ask Question on Bubble sort c program, Get Answer, Expert's Help, Bubble sort c program Discussions

Write discussion on Bubble sort c program
Your posts are moderated
Related Questions
print this pattern 1 01 101 0101

Program to sort a range of numbers with Insertion: /* define variable */ const int max=29000; int list[max]; FILE *fp; clock_t start,end; char any1[8];

Write a C++ program that can be used to evaluate the credit worthiness of a client. The program reads the credit limit and the price and quantity of the item to be purchased by the

write a c++ program for minimum shelf downloads

Program to design text styles: Write a C program to design different text style char *fname[] = { "DEFAULT font",                                   "TRIPLEX font",

what is a string?

Write a C program to compute the value of a sine wave from 0 to 2P with an increment of 0.1 radians.   #include stdio.h #include math.h #define pi 3.1415927 void main() {   c

6999066263304447777077766622337778 -----> message sent by the first smuggler. my name is robert---------> message decoded by the second smuggler. Where ‘0’ denotes the "space".


A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of t