boolean problem

I am trying to make a program that compares two numbers in two arrays and display if they are the same or not... the problem with my program is that it always displays that they are the same even if they are not. What is wrong with my code?

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
bool bank(double[], double[], int);

int main()
{
	bool result = false;
	double userentered[4];
	double set[4] = {1, 4, 5, 8};

	cout <<"enter the numbers"<<endl;
	for (int i = 0; i < 4; i++)
	{
		cin>>userentered[i];

	}

	result = bank(set, userentered, 4);
	
	if (result == true)
	{
		cout<<"The number is equal"<<endl;
	}
	else
	{
		cout <<"The number is not equal"<<endl;
	}
}

bool bank(double set[], double userentered[], int number)
{
	bool result; 
	for(int i = 0; i<number; i++)
	{
		if (set[i] == userentered[i])
		{
			result = true;
		}
	}
	return result;
}
You forgot to initialize result on line 30.
Wow didn't see that. Thank you!
Topic archived. No new replies allowed.