Input Array Values and Compare

Okay so I have an assignment that asks me to create a program to compare two arrays. The program has to be made up of 4 functions. One function to ask the user to input integers into an array of size 10 (This function will be called twice so the user fills two arrays (for comparison). I also need another function that will compare the arrays that will return a boolean indicating if the arrays are the same or not. Another function to print the two arrays. And finally another function that will show the results of the function that compared the arrays.

Here what I have in mind of what the code should look like

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
#include <iostream>

using namespace std;

void fill_array()
{
    
}

bool check_if_identical()
{

}

void print_array()
{

}

void comparison_result()
{

}

int main()
{
    fill_array();

    fill_array();

    check_if_identical();

    print_array();

    comparison_result();

    return 0; 
}


Here is what I have done so far:

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
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>

using namespace std;

void fillarray(int c[], int size = 10)
{
	int c[size];

	cout << "Enter 10 digits:" << endl;

	for (int i = 0; i < size; i++)
	{
		cin >> c[i];
	}
}

bool identcheck(int a[], int b[], int size = 10)
{
	for (int j = 0; j < size; j++)
	{
		if ( a[i] == b[i])
		{
			return true;
		}
		else 
		{
			return false;
		}
	}
}

void arrayprint()
{
	cout << a

}

void identresult()
{

}

int main()
{
	void fillarray(int arra1[], int size = 10);

	//int arra1[10] = {a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]};

	void fillarray(int arra2[], int size = 10);

	//int arra2[10] = {a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]};

	void identcheck(arra1, arra2);
	void arrayprint();
	void identresult();
}


I am not very good with functions. I know that the parameters are wrong and any help would be appreciated. How do I pass arrays through functions?
How do I pass arrays through functions?

like this
1
2
int arr[10];
fillarr(arr);



I know that the parameters are wrong
void fillarray(int c[], int size = 10)
to
void fillarray(int c[], int size)

void fillarray(int arra1[], int size = 10);
to
void fillarray(arra1[],10);


1
2
3
4
5
6
7
8
9
10
11
for (int j = 0; j < size; j++)
	{
		if ( a[i] == b[i])
		{
			return true;
		}
		else 
		{
			return false;
		}
	}

you only check to see if the first value is a match?

try this
1
2
3
4
5
6
7
8
9
10
11
12
13
bool identcheck(int a, int b)
{
	return a == b;
}
bool identresult(int a[], int b[])
{
	for (int i = 0; i < 10; i++)
	{
		if (!identcheck(a[i], b[i]))
			return false;
	}
	return true;
}

Last edited on
Topic archived. No new replies allowed.