change the inner loop as follows-
*for(j=i+1;j<5;j++)*

Cheers,
Bharat

On Thu, Aug 26, 2010 at 11:33 AM, COOL DUDE <cooldude9...@hotmail.com>wrote:

> #include<iostream.h>
> #include<conio.h>
> void main()
> {
> int array[5],i,j,temp=0;
> clrscr();
> cout<<"Enter any five number:\n";
> for(i=0;i<5;i++)
> {
> cin>>array[i];
> }
>
> for(i=0;i<5;i++)
> {
> for(j=1;j<5;j++)
> {
> if(array[i]>array[j])
> {
> temp=array[i];
> array[i]=array[j];
> array[j]=temp;
> }
> }
> }
>
> cout<<"The sorted array is:";
> for(i=0;i<5;i++)
> {
> cout<<"\n"<<array[i];
> }
> getch();
> }
>


[Non-text portions of this message have been removed]

Reply via email to