Program

SoccerBoss
Category:
Programming
Price: $10 USD

Question description

Hello, I have 3 problems that I would ask for your help to answer it. Below are the first problem. 

Write a program largeHalf.c that takes in a list of 8 integers, splits the list into two halves (first 4 elements, last 4 elements), sums the elements in each half, selects the half with the larger sum, and then repeats this process with the selected list until there is only one element selected. The program should print out the half selected at each step. If the two halves have equal sum, the program should tell the user this and should always pick the first half (the one with a smaller starting index, see the example output below).

Your program must include the following functions:• int sumArray(int array[], int startIdx, int len)-Returnsthesumofthe

elements in array with index startIdx to startIdx+len.• void printArray(int array[], int startIdx, int len)-Printtheelements

in array with index startIdx to startIdx+len.
We suggest implementing and testing each of these functions before completing the full program.

( ̃)$ a.out

Enter 8 numbers: 1 2 3 4 5 6 7 8

Larger half is 5 6 7 8 

Larger half is 7 8 

Larger half is 8

( ̃)$ a.out

Enter 8 numbers: 1 2 3 4 5 4 1 0

The two halves are equal, picking 1 2 3 4 

Larger half is 3 4

Larger half is 4

( ̃)$ a.out

Enter 8 numbers: 1 4 5 0 -10 10 1 2 

Larger half is 1 4 5 0

The two halves are equal, picking 1 4 

Larger half is 4



Tutor Answer

(Top Tutor) Daniel C.
(997)
School: Cornell University
PREMIUM TUTOR
Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1827 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors