What't wrong?

#include<iostream>

using namespace std;
void main(){
int i,j;
int min;
int t;
int a[10];
cout<<"enter 10 numbers:"<<endl;
for(i=0;i<10;i++)
cin>>a[i];
for(i=0;i<10;i++)
{for(j=i+1;j<10;j++)
min=i;
if(a[min]>a[j])
min=j;
if(min!=i)
{t=a[i];
a[i]=a[min];
a[min]=t;}
}
for(i=0;i<10;i++)
cout<<a[i]<<endl;
return;

}
Your main function should return int, not void:
1
2
3
4
5
int main()
{
    // do stuff
    return 0;
}


You should put your code in [code] tags: http://www.cplusplus.com/forum/articles/16853/

And you are overstepping your array bounds in a couple of places.
Last edited on
Thank you!
Topic archived. No new replies allowed.