C++ using functions to deal with arrays?

Hi, I'm pretty new to C++ language and I have a question about this code as it has been driving me crazy.
I have to use specific functions for an assignment, however when I use the function populate_array (), an error keeps popping up that says that it must return a value. I have tried messing around with it, but i'm at a loss.
My code so far is seen below:
I need the program to populate the array with integers entered by the user and then display the array later as part of a string for now, I still have to add more functions later. Any help would be greatly appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  #include <iostream>
const int ArSize = 6;

void display_array(const double ar[], int n);
int populate_array(double ar[], int limit);

int main()
{
	using namespace std;
	cout << "This program takes integars and puts them into an array. They are later manipulated." << endl;
	int array[6];
}
	int populate_array(double ar[], int limit)
{
	using namespace std;
	
	for (int i = 0; i < 6; i++)
	{
		cout << "Please enter an integar: " << endl;
		cin >> ar[i];
		populate_array(ar, 6);
	
	}

	void display_array(const double ar[], int n);
	{
		cout << "The elements of the array are: " << display_array << endl;
	}

}
You told your compiler that populate_array returns an int, yet you don't have a single return statement in your function body. Either mark the return type void or return a value in all cases.
Topic archived. No new replies allowed.