Code starts from next line :
---------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int i, j, size, name[20], temp;
cout<<"\nHow many numbers:";
cin>>size;
cout<<"\nEnter the 1 d arrays:";
for(i = 0; i < size; i++)
{
cin>>name[i];
}
for(i = 0; i < size; i++)
{
for(j = 0; j < size-i-1; j++)
{
if(name[j] > name[j+1]) //just replace > by < for descending order.
{
temp = name[j];
name[j] = name[j+1];
name[j+1] = temp;
}
}
}
cout<<"\nAccending order is:";
for(i = 0; i < size; i++)
{
cout<<" "<<name[i];
}
getch();
}
4 comments:
Hey morons!! try putting proper indentation & tab-spaces.
Great! thx boy
header file iostream.h is not valid (must take out .h", forgot using namespace std, ascending and descending change comment works fine. overall a pretty good code
it was really nice ...thank u soo much it helped me .thank u.....
Post a Comment