Can someone kinda check this one to see what wrong with it?

``````#include <iostream>
using namespace std;

int ture ( int a[], int b[], int d);
int main ()
{
int b [5]={1,2,3,4,5};
int a [5] ={1,2,3,4,5};

int total= ture(b, a, 5);
cout << total << endl;
}
int ture ( int a[], int b[], int d)
{
const double NUM = 10;
for (int d = 0; d < 10; d++)
{
if (a[d] != b[d])
{
return false;
}
}
return true;
}
``````

## All 7 Replies

The arrays are fine! Do you have another problem with the code?

Doesn't this for loop run past your arrays?

``````for (int d = 0; d < 10; d++)//arrays have five elements
{
...
}
``````

This function returns int but you return boolean inside the function. What does this function accomplish?

``````int ture ( int a[], int b[], int d)
{
const double NUM = 10;
for (int d = 0; d < 10; d++)
{
if (a[d] != b[d])
{
return false;
}
}
return true;
}
``````

i need to return ture if they are equal and false otherwise

right now i try to run it. It show some kinda error.

Try looking at the function here:

``````#include <iostream>

using namespace std;
int ture ( int a[], int b[], int d);

int main ()
{
int b [5]={1,2,3,4,5};
int a [5] ={1,2,3,4,5};

cout << ture(b, a, 5) << endl;
}

int ture ( int a[], int b[], int d)
{
for (int i = 0; i < d; i++)
{
if (a[i] != b[i])
{
return false;
}
}
return true;
}
``````

oh i ok. But I need to 2 array of lenght 10. do i need double num=10?

oh wait... why you return I not D?

I'm at a complete lose as to what you are trying to accomplish here...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.