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

Write a complete program in C++ that does the following: ( PLEASE provide me wit

ID: 3788722 • Letter: W

Question

Write a complete program in C++ that does the following: ( PLEASE provide me with full answer, Its in my coming test.)

* Write a function called arraySum that calculates and returns the sum of entries in a specified one-dimensional array.

* Write a function called rowSum that calculates the sums of each row in a given two-dimensional array and returns these sums in a one-dimensional array. This function has two parameters, a two-dimensional array Array, TwoD of integer values and a one-dimensional array called ArrayD. ArrayTwoD is in row major order. This function returns a one-dimensional array with one entry for each row of ArrayTwoD such that each entry is the sum of the corresponding row in ArrayTwoD. You must use the function called arraySum appropriately to get full credit.

* A two-dimensional array is considered to be divers if no two of its ros have entries that sum to the same value. Write a function called Is Diverse that determines whether or not a given two-dimensional arrays is diver. This function has one parameter: a two-dimensional array arrayTwoD of integer values and should return true if all the row sums in the given array are unique; otherwise, it should return false. You must use the function called rowSum appropriately to get full credit

Explanation / Answer

Here are the three functions for you:

#include <iostream>
#include <array>
#define ROWS 10
#define COLS 10
using namespace std;
/* Write a function called arraySum that calculates and returns the sum of entries in a
specified one-dimensional array.*/
int arraySum(int array[])   
{
int sum = 0;
for(int i = 0; i < COLS; i++)
sum += array[i];
return sum;
}

/* Write a function called rowSum that calculates the sums of each row in a given
two-dimensional array and returns these sums in a one-dimensional array. This function
has two parameters, a two-dimensional array Array, TwoD of integer values and a
one-dimensional array called ArrayD. ArrayTwoD is in row major order. This function
returns a one-dimensional array with one entry for each row of ArrayTwoD such that each
entry is the sum of the corresponding row in ArrayTwoD. You must use the function
called arraySum appropriately to get full credit.*/
int* rowSum(int ArrayTwoD[][COLS], int ArrayD[])
{
for(int i = 0; i < ROWS; i++)
ArrayD[i] = 0;
for(int i = 0; i < ROWS; i++)
for(int j = 0; j < COLS; j++)
ArrayD[i] += ArrayTwoD[i][j];
return ArrayD;
}
/* A two-dimensional array is considered to be diverse if no two of its rows have entries
that sum to the same value. Write a function called Is Diverse that determines whether
or not a given two-dimensional arrays is diver. This function has one parameter: a
two-dimensional array arrayTwoD of integer values and should return true if all the row
sums in the given array are unique; otherwise, it should return false. You must use the
function called rowSum appropriately to get full credit*/
bool isDiverse(int ArrayTwoD[][COLS])
{
int *ArrayD;
ArrayD = rowSum(ArrayTwoD, ArrayD);
for(int i = 0; i < ROWS; i++)
for(int j = i+1; j < COLS; j++)
if(ArrayD[i] == ArrayD[j])
return false;
return true;   
}   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote