C program for bubble sort, C/C++ Programming

C program for bubble sort:

void main()

{

int i,j,k,a[10],n;

clrscr();

printf("How many values you want to enter\n");

scanf("%d",&n);

 for(i=0;i<=n-1;i++)

 {

 printf(" %d no?\n",i+1);

 scanf("%d",&a[i]);

 }

                for (i=0;i<=n-1;i++)

                for(j=0;j

                 {

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

                    { k=a[j+1];

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

                      a[j]=k;

                     }

                  }

 for(i=0;i<=n-1;i++) printf("%d\n",a[i]);

 getch();

 }

Posted Date: 10/18/2012 6:29:56 AM | Location : United States







Related Discussions:- C program for bubble sort, Assignment Help, Ask Question on C program for bubble sort, Get Answer, Expert's Help, C program for bubble sort Discussions

Write discussion on C program for bubble sort
Your posts are moderated
Related Questions
The code contains two built-in pitfalls. First one, if it executes in a member function for an static, extern or automatic object, the program will possibly crash as soon as the de

Converting Base Type to Class Type (char to string)   class String { char *name; int length; public: String(void) {length =0; name = new char[length+1];


program to check whether a given point lies inside a rectangle or not

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

Padovan String Problem Description 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 s

Define Bit Fields Bit Fields permits the packing of data in a structure. This is particularly useful when memory or data storage is at a premium. Usual examples: Packing

Implementation of the Stack class in C++: How to implement stack class in c++. int Stack::push(int elem) {    if (top    {       list[top++] = elem;       r

Define Functions with arguments and no return values The calling function will read a data from the terminal and pass it on to called as function and this will work good as the

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b