hi. im new to this sorting stuff so please help me out here.
im assign to input 10 numbers, then sort then to descending order.
my problem is after i input 10 number there some negative numbers popping out that i dont know where it came and then the program ends....
Y_Y help me pls i need this done tommorrow.
#include <iostream>
using namespace std;
int main()
{
int a[10];
int i,j,temp,flag=0;
for(i=1,j=0;i<11,j<10;j++,i++)
{
cout<<"Enter number"<<i<<": ";
cin>>a[j];
}
for (i=0;i<10;i++)
{
for(j=0;j<(10-i);j++)
{
if (a[j]<a[j+1])
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
for(i=0;i<10;i++)
cout<<a[i];
return 0;
}
Here is some code to do an ascending sort, I will leave it up to you to change it to descending.
You will also need to understand the code and change it, as your teacher will know that you have not written this.