Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the definition of a function, isReverse , whose first two parameters are a

ID: 3620531 • Letter: W

Question

Write the definition of a function, isReverse , whose first two parameters are arrays of integers of equal size, and whose third parameter is an integer indicating the size of each array. The function returns true if and only if one array is the reverse of the other. ("Reverse" here means same elements but in reverse order.)


Given a two-dimensional array of integers named q, with 2 rows and 4 columns, write some code that puts a zero in every element of q. Declare any variables needed to help you.


You are given a 6x8 (6 rows, 8 columns) array of integers, x, already initialized and three integer variables: max, i and j. Write the necessary code so that max will have the largest value in the array x.

Explanation / Answer


#include
using namespace std;
bool isReverse(int[],int[],int);
int main()
{int a[]={1,2,3,4,5,6};
int b[]={6,5,4,3,2,1};
int c[]={6,5,4,3,4,5};
int size=6;
if(isReverse(a,b,size))
    cout<<"a and b are the reverse of each other ";
else
    cout<<"a and b are not the reverse of each other ";
if(isReverse(a,c,size))
    cout<<"a and c are the reverse of each other ";
else
    cout<<"a and c are not the reverse of each other ";
system("pause");
return 0;
}
bool isReverse(int a[],int b[],int c)
{bool retval=true;
int i,j;
i = 0; /* first element */
j = c - 1; /* last element */
do {
if (a[i] != b[j]) {
retval=false; /* lists are not equal */
break; /* don't need to do any more checks */
}
else {
i++; /* C language shorthand to increment i */
j--; /* C language shorthand to decrement j */
}
} while (i < c);
return retval;
} #include
using namespace std;
bool isReverse(int[],int[],int);
int main()
{int a[]={1,2,3,4,5,6};
int b[]={6,5,4,3,2,1};
int c[]={6,5,4,3,4,5};
int size=6;
if(isReverse(a,b,size))
    cout<<"a and b are the reverse of each other ";
else
    cout<<"a and b are not the reverse of each other ";
if(isReverse(a,c,size))
    cout<<"a and c are the reverse of each other ";
else
    cout<<"a and c are not the reverse of each other ";
system("pause");
return 0;
}
bool isReverse(int a[],int b[],int c)
{bool retval=true;
int i,j;
i = 0; /* first element */
j = c - 1; /* last element */
do {
if (a[i] != b[j]) {
retval=false; /* lists are not equal */
break; /* don't need to do any more checks */
}
else {
i++; /* C language shorthand to increment i */
j--; /* C language shorthand to decrement j */
}
} while (i < c);
return retval;
}
You are given a 6x8 (6 rows, 8 columns) array of integers, x, already initialized and three integer variables: max, i and j. Write the necessary code so that max will have the largest value in the array x. #include
using namespace std;
int main()
{int x[6][8]={0,0};
int i,j,max;
//easiest way to initialize the array
for(i=0;i<6;i++)
     for(j=0;j<8;j++)
         x[i][j]=rand()%200+1;
cout<<"The array ";
for(i=0;i<6;i++)
     {for(j=0;j<8;j++)
         cout<      cout<         }
cout< max=x[0][0];
for(i=0;i<6;i++)
     for(j=0;j<8;j++)
         if(x[i][j]>max)
             max=x[i][j];
cout<<"The largest value is: "<
You are given a 6x8 (6 rows, 8 columns) array of integers, x, already initialized and three integer variables: max, i and j. Write the necessary code so that max will have the largest value in the array x. #include
using namespace std;
int main()
{int x[6][8]={0,0};
int i,j,max;
//easiest way to initialize the array
for(i=0;i<6;i++)
     for(j=0;j<8;j++)
         x[i][j]=rand()%200+1;
cout<<"The array ";
for(i=0;i<6;i++)
     {for(j=0;j<8;j++)
         cout<      cout<         }
cout< max=x[0][0];
for(i=0;i<6;i++)
     for(j=0;j<8;j++)
         if(x[i][j]>max)
             max=x[i][j];
cout<<"The largest value is: "< #include
using namespace std;
int main()
{int x[6][8]={0,0};
int i,j,max;
//easiest way to initialize the array
for(i=0;i<6;i++)
     for(j=0;j<8;j++)
         x[i][j]=rand()%200+1;
cout<<"The array ";
for(i=0;i<6;i++)
     {for(j=0;j<8;j++)
         cout<      cout<         }
cout< max=x[0][0];
for(i=0;i<6;i++)
     for(j=0;j<8;j++)
         if(x[i][j]>max)
             max=x[i][j];
cout<<"The largest value is: "<