Thanks @TarikNeaj mate :)
After fighting for 2 hours with my program..
Sorting error just nearly injured my brain
I'm still unable to find logical error.. this program runs fine but does not outputs in incorrect sorted order
#include <iostream>
#include <Windows.h>
#include <time.h>
usingnamespace std;
int main ()
{
int Array[60];
time_t t; time (&t);
srand((unsignedint) t); // seed srand() function with system time
cout<<"Array elements in original generated order: "<<endl<<endl;
for (int k=0; k<60; k++)
{
Array[k]=rand()%100;
cout<<Array[k]<<" ";
}
int temp; // temporary variable to hold Array element while sorting
for (int k=0; k<59; k++)
{
if (Array[k]>Array[k+1])
{
temp=Array[k+1];
Array[k+1]=Array[k];
Array[k]=temp;
}
}
cout<<"\n\nArray elements in ascending order: "<<endl<<endl;
for (int k=0; k<60; k++)
{
cout<<Array[k]<<" ";
}
cin.get();
return 0;
}