Program in C++ to Search a no. Using (Bubble Sorting Method)
5:29 AMuse header files iostream.h and conio.h then
void main()
{ clrscr();
int a[100],i,n,j,temp;
cout<<"How many element: ";
cin>>n;
cout<<"Enter the elements of array:
"<
for(i=0;i
cin>>a[i];
cout<<"The elements of array Before Sorting:
"<
for(i=0;i
for(i=0;i
{
for(j=0;j
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
} }
cout<<"Elements of array After Sorting:
"<
for(i=0;i
getch();}
Output:-
How many element: 3
Enter the elements of array:
5 4 9
The elements of array Before Sorting:
5 4 9
Elements of array After Sorting:
4 5 9
0 comments