hey all, hope you're having a fine weekend all i'm trying to do here is load an array and sort it, but i think my logic doesn't follow. i think the problem is in the sorting. thanks in advance
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
main()
{
int const array_size=400;
int array[array_size], holder;
//seed
srand(time(0));
//load, sort & display array
for (int i=0; i<array_size; i++)
{ array[i]=1+rand() %array_size*2;
if (array[i]<array[i-1]&&i>0)
{ holder=array[i];
array[i]=array[i-1];
array[i-1]=holder;
}
cout<<array[i]<<" ";
}
return(0);
}