10:53 AM
C++ Programming for BUBBLE SORT

Write a Program of BUBBLE SORTing

#include<iostream.h> 
#include<conio.h>

void main()

{

int s,temp,i,j,a[20];

clrscr();

printf("\nEnter size of the array: ");

scanf("%d",&s);

printf("\nEnter %d elements in to the array:",s);

for(i=0;i<s;i++)

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

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

{

for(j=0;j<s-1-i;j++)

{

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

{

temp=a[j];

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

a[j+1]=temp;

}

}

}

printf("\nThe array after sorting is: ");

for(i=0;i<s;i++)

printf(" %d",a[i]);

getch();

}

Note:
      If you want to change in this program please write through the comment on this page. you can also past similar program 
                 of c++ with output.your comment is valuable to the other user and person.
Views: 99 | Added by: vijoriya | Tags: BUBBLE SORT, C++ Program | Rating: 0.0/0
Total comments: 0
avatar