hey guys, I am fairly new to c++ and I was trying to finish this code for my last lab. I've tried almost everything but some reason I can not get my numbers to present themselves correctly.
#include <iostream>
using namespace std;
void sSort(int [],int);
void myArray(const int [], int);
int main()
{
const int size = 10;
int values[size];
int n;
cout << " Enter any some numbers : ";
cin >> n;
myArray (values,size);
sSort(values, size);
cout << " These are your ascending numbers :" << endl;
myArray (values,size);
return 0;
}
void sSort(int array[], int size)
{
int start, minIndex, minValue;
for (start = 0; start < (size -1); start++)
{
minIndex = start;
minValue = array[start];
for(int index = start + 1; index < size; index++)
{
if (array[index] < minValue)
{
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[start];
array[start] = minValue;
}
}
void myArray(const int array[], int size)
{
for (int count = 0; count < size; count++)
you got myArray function right.
reading into the array is pretty much the same idea:
cin >> values[index];
you are not reading anything into the array, and then printing the uninitialized array which is full of junk.