here is what i have to do: take 2 double array of lenght 10 call a and b and return ture if they are equal and flase otherwise; and write a function that take a and b and return and array which store the sum of correspond elemets. can someone check if this correct or not or show me how to do to check?

here is what i got so far:

``````cosnt double NUM = 10
double a [NUM]
double b [NUM]
bool c
int d =0
for (d=0; d < 10; d++)
{
if (a[d] != b[d])
{
c= false
}
else
{
c=true
}
}
return 0;

2nd one is this:
const int NUM = 10
int a [NUM];
int b [NUM];
int c=0
for (int d = 0; d < e ; d+)
{
if (int e=0;e<b; e++)
{
c+=a+b;
}
}
``````

Well, you have a few typos in your code, and then, you forgot the end the lines with a semi-colon `;` almost everywhere. With those small corrections, we get:

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

which mainly has one problem: it does not return the true/false that it is supposed to. The thing to realize here is that if you see a single mismatching pair of numbers, there is no point in continuing to look at the other numbers, because you already know that you can't have two identical arrays. And so, you can return false as soon as you see a mismatch, and return true if you made it to the end without an issue:

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

That takes care of the logic of the loop for the first problem. However, I don't see any function signatures or where the numbers in the arrays are taken from. And without that, it is kind of hard to move forward. Can you please post the complete program, not just short excerpts.

Instead of looping throught the arrays, I would try a function like memcmp().

Thank you for rely, Mike. I just need to do a part of problem not all whole thing! Mike or someone kind look through my 2nd code? Here is question: write a function that take a and b and return and array which store the sum of correspond elemets. Thank you very much for help.

You can use comp() function to check the matchng arry words .

how because i never learn comp()