Quantcast
Viewing latest article 29
Browse Latest Browse All 42

Answer by Karthik T for Write the definition of a function, isReverse

The return value is wrong because you are checking only 1 value from each array, not all of them. What you want to do is something like this.

for (i=0;i<size;i++){    if(!(array1[i] == array2[size-i-1]))        return 0;}return 1;

Basically you go through the array one by one, if any of the values are not the same as the appropriate value on the other array, it is not a reverse, so we return 0. If we get out of the for loop without going through the if, it means they are reverses so we return 1.


Viewing latest article 29
Browse Latest Browse All 42

Trending Articles