Arrays and functions

Hey guys i am learning about how to use arrays and functions and i am getting this error (undefined reference to 'print (int const* , int ) '
what seems to be the problem?
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <ctime>

using namespace std;

void initialize(int list[],int);
void fil (int list[],int);
void print (const int list[],int);
int sum (const int list[],int);
int largest (const int list[],int);
void copyArray(const int list[],int list2[],int);



int main (){

int nums1[10]={0};
int nums2[10];
int size =10;
cout <<"nums elements :" ;
print (nums1,10);
cout<<endl;
initialize(nums2,size);
cout<<"nums elements : ";
print (nums2,size);
cout<<endl<<endl;
cout<<"Enter "  <<size<<"integers:";
fil(nums1,size);
cout<<endl;
cout<<"nums1 elements:";
print(nums1,size);
cout<<endl;
cout<<"sum elements of nums1 = "<<sum(nums1,size)<<endl;
cout<<"position of largest element in nums1 ="<<largest(nums1,size)<<endl;
cout<<"Largest element in nums1 = "<<nums1[largest(nums1,size)]<<endl;
cout<<"nums2 elements :";
print(nums2,size);
cout<<endl;
copyArray(nums1,nums2,size);
cout <<"after copy elements of nums2 :";
print (nums2,size);
cout<<endl;

return 0;
}
you are only showing us main().
Where do you define the print function or for that matter, any of the functions you have prototypes for on lines 6 to 11?

If this is a practice problem, you must define the function yourself above or below main

1
2
3
4
void print (const int list[],int n)
{
 // print array code
}

You must do this for all the functions you prototyped
Last edited on
Topic archived. No new replies allowed.