Write a program, which will ask the user how many whole numbers they wish to enter. The program will then read that many numbers, print them in the order they were entered, sort them in order by increasing value, and print them in sorted order.
All numbers entered and displayed will be integer values.
All numbers must be validated upon entry.
The maximum number of integers to be handled will be 20.
Sorting will be done in a function where the array will be the first parameter and the number of integers entered into the array will be the second parameter.
void main() {
int Num;
char Array[20]; // this should be an int, however when i change it to int, errors occur at bubblesort.
//Program runs, up until it sorts when Array [20] is a char, the numbers are into characters and then blows up.
cout << "How many numbers would you like to enter?" << endl;
cin >> Num;
cout << "Enter your numbers:" << endl;
for (int i = 0; i < Num; i++) {
cin >> Array[i];
}
cout << "Here are the numbers you entered:" << endl;
for (int i = 0; i < Num; i++) {
cout << Array[i] << " ";
}
cout << endl << endl;
BubbleSort(Array); //bubblesort is a char, so i get a int incompatible with char error
// This bubblesort function was given to us be the professor to use for this lab
cout << "Here are your sorted numbers:" << endl;
for (int i = 0; i < Num; i++) {
cout << Array[i] << " ";
}
cout << endl;
}
/////////////////////////////////////////////////////////////////////////////
So pretty much, I believe my code is correct minus the issue noted above. Can anyone help? Can provide the header file and other .cpp file i have, prefer not to post my entire code on the web.