Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Wednesday, April 21, 2010

This program is used for Bubble sort. (C++)


 
 
#include< iostream.h>
#include< conio.h>
#include< stdlib.h>
void bubble_sort(int array[],int size)
{
int temp,i,j;
for(i=0;i< size;i++)
for(j=0;j< size-i-1;j++)
if(array[j]< array[j+1])
{
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
void main(void)
{
clrscr();
int values[30],i;
cout< < "Unsorted list is as follows\n";
for(i=0;i< 10;i++)
{
values[i]=rand()%100;
cout< < values[i]< < " ";
}
bubble_sort(values,10);
cout< < "\nSorted list is as follows\n";
for(i=0;i< 10;i++)
cout< < values[i]< < " ";
}

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP