Question: Prob 3. Write a function called largestGap that returns the largest gap between two adjacent elements of an array. For example, a program that uses

Prob 3. Write a function called largestGap that returns the largest gap between two adjacent elements of an array. For example, a program that uses the function largestGap follows, it prints 7 since the largest gap is between the 9 and the 2.

int main() { int x[] = {3, 1, 4, 1, 5, 9, 2, 6};

cout << largestGap(x, 8) << endl; // prints 7

return 0;

}

(just the function ); example-

(Answer: int removeLast7(int n) { if (n == 0) return 0;

if (n % 10 == 7) return n/10; return 10 * removeLast7(n/10) + n%10;)this is an example .

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 Databases Questions!