Program to sort an Integer Array in descending order | C++ Programming

//Program to sort an Integer Array in descending order
#include <iostream.h>
#include <conio.h>
void main()
{clrscr();
int n,i,j,B[10],temp ;
cout <<"\n enter the number of element :";
cin>>n;
for (i=0; i<n ; i++)
{cout <<"\n enter B["<<i<<"] element :";
cin>>B[i];
}
cout <<"\n original array :";
for (j=0; j<n; j++)
cout <<"\n B["<<j<<"]="<<B[j];
for(i=0;i<n; i++)
{for(j=0;j<n-i-1; j++)
{if(B[j] <B[j+1])
{temp=B[i];
B[j]=B[j+1];
B[j+1]=temp;
  }
 }
}
cout<<"\n decending order of array is :";
for(j=0;j<n;j++)
cout<< B[j]<<">";
getch();
}
Program to sort an Integer Array in descending order | C++ Programming Program to sort an Integer Array in descending order | C++ Programming Reviewed by SHERE KHOJRAHA on February 13, 2019 Rating: 5

No comments:

Powered by Blogger.