Hello,
I'm having trouble with one of my coding assignments. I have to compare 2 arrays to see if they're identical. My code compiles fine, but i'm not getting the correct results. Mind you I'm in a beginner's course so I cannot have any advanced coding, I appreciate those suggestions, but again I cannot use them in my assignment.
#include <iostream>
#include <iomanip>
using namespace std;
bool compare_arrays(int a[], int b[]);
int main()
{
int i;
int list1[5];
int list2[5];
cout << "Please enter a series of numbers (up to 10) for your first array: " << endl;
cin >> list1[5];
cout << "Please enter a series of numbers (up to 10) for your second array: " << endl;
cin >> list2[5];
cout << "The arrays are: "
<< compare_arrays(list1, list2)
<< endl;
return 0;
}
bool compare_arrays(int a[], int b[])
{
bool answer = true;
for (int i = 0; i < a[i]; i++)
{
if(a[i] == b[i])
{
return true;
}
else
return false;
}
}
When I enter my array values, I keep getting "The arrays are: 0" I don't know what I'm doing wrong