Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2 (a) Type a C++ function named checkSecondHalf that takes an integer array and swaps the first half and the second half of the array.

Q2 (a) Type a C++ function named checkSecondHalf that takes an integer array and swaps the first half and the second half of the array.

Take this sample into account: When calling the function on array [4,5,6,1,2,3] will change it to [1,2,3,4,5,6]. Now, lets say if the total number of elements in the array is an odd number then the middle element should remain at its original position. For example, calling the function on array [12,18,3,5,7] will change it to [5,7,3,12,18]. Try using logic that is simple and easy to understand and avoid using other library functions.

Q2 (b) Type a C++ function named comesSecondLargest that returns the second largest element in the integer array. You may assume that all array elements are different.

Take this sample into account: if the array given is {-4,7,2,-12}, the function should return 2. Try using logic that is simple and easy to understand and avoid using other library functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Describe the sources of long term financing.

Answered: 1 week ago