Hello, this is my first time posting a question on this website. I have read the tutorial on arrays and functions , but I am still having a problem with writing the code for the following problem:
I'm supposed to write two void functions as described below:
void getIntArrayFromUser(int theArray[], int size)
void displayIntArrayToConsole(int theArray[], int size)
The first function is supposed to ask the user for values and store them into theArray[] and the second function is supposed to display all the values in a single line separated by spaces or commas.
This is what I have so far in my code:
1 2 3 4 5 6 7 8 9
|
#include <iostream>
using namespace std;
void getIntArrayFromUser(int theArray[], int size)
{
cout << "please enter your values: ";
cin >> size
}
|
Is this right to get the values into the array?
I have no clue what to put in this area so that I can display those values:
1 2
|
void displayIntArrayToConsole(int theArray[], int size)
|
This is what I have for my main function:
1 2 3 4 5 6
|
int main ()
{
cout << "The values in the array are: ";
displayIntArrayToConsole(values, size);
return 0;
}
|
Am I on the right track? Any advice or help would be appreciated! Thank you.