#include <iostream>
#include <cstdlib>
using namespace std;
const int MAX_ARRAY_SIZE = 11;
void instructions();
//Explains the program to user.
void get_integers(int a[],int size);
//Recieves input from user
int main(){
int numbers[MAX_ARRAY_SIZE];
instructions();
get_integers(numbers,MAX_ARRAY_SIZE);
for(int i = 0;i < MAX_ARRAY_SIZE;i++){
cout << numbers[i] << " ";
}
return 0;
}
void instructions(){
using namespace std;
cout <<"\nThis program reads 10 integers from you";
cout <<"and sorts them from smallest to largest\n";
}
void get_integers( int a[], int size) {
using namespace std;
int index;
int numbers[MAX_ARRAY_SIZE];
// Use loop-and-a-half to fill array
cout << "Enter"<< size << "integers: ";
for(index = 0; index < MAX_ARRAY_SIZE; index++)
cin >> numbers[index];
}
I'm trying to fill an array of 10 integers for a program that takes in 10 numbers from the user and the program sorts them in ascending order. I don't want to have to prompt every time for the number i want the user to be able to enter in each number by just having a space in between each. My code seems right for handling that but when I run the program it does not do anything when I put in the 10 numbers.. ANY help would be greatly appreciated!