can someone help me to get my program to sort i have the logic but this is my first time doing a sort program and i cant get it to work can some tell me what i'm doing wrong
#include <iostream>
#include <iomanip>
using namespace std;
void sort();
const int LIMIT = 50;
int MYARRAY[LIMIT];
int value,i;
int x = 0;
int print = 0;
int j,temp,min,minx;
int main()
{
bool exit = false;
while(!exit && x < LIMIT)
{
cout<<"Enter a number or 999 to quit ";
cin>>value;
if(value != 999)
{
MYARRAY[x] = value;
x++;
}
else
{
exit = true;//if value equals 999 exit the loop
}
while(print < x)
{
cout<<MYARRAY[print]<<endl;//print out the number as long as it is less than i
print++;
}
}
sort();
return 0;
}
void sort()
{
min=MYARRAY[x];
minx=i;
for(j=i+1;j<x;j++)
if(MYARRAY[j]<min)
{
min=MYARRAY[j];
minx=j;
}
if(min<MYARRAY[x])
{
MYARRAY[x]=min;
MYARRAY[minx]=temp;
}
for(int a=0;a<x;a++)
cout <<setw(4) << MYARRAY[x]<< endl;
}