Question: Write a C + + function called goodArray that takes a reference to an integer array called arr and does the following: Prints Good if

Write a C++ function called goodArray that takes a reference to an integer array called arr and does the following:
Prints "Good" if there is an element in the array, called "BigNumber," whose value equals the sum of all even elements (excluding itself).
Prints "VeryGood" if you can swap the "BigNumber" with any other element to make the array a palindrome (if the array is printed from left to right or printed from right to left the result is the same).
Otherwise, prints "NO".
For example:
For the array arr =[1,2,4,2], the output is "Good" because arr[2]=4 is equal to the sum of all even elements (arr[2]=arr[1]+arr[3]).
For the array arr=[2,3,2,3,4], the output is "VeryGood" because arr[4]=4 is equal to the sum of all even elements. Additionally, swapping it with arr[2] makes the array a palindrome.
For the array arr =[1,2,3,4,5], the output is "NO". because there is no BigNumber.
1=
2=
Write a C + + function called goodArray that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!