# C programming

Nov 27th, 2013
Steve1995
Category:
Programming
Price: \$15 USD

Question description

hello,

I have a midterm coming up and I can't figure out one of the practice problems. I think I have the first function done right, but I can't seem to repeat it. Also, I don't know how to use the second function to print out the values.

I'm supposed to write a program largeHalf.c that takes in a list of 8 integers, splits the list into two halves (rst 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 rst half (the one with a smaller starting index, see the example output below).

must include the following functions:
int sumArray(int array[], int startIdx, int len) - Returns the sum of the elements in array with index startIdx to startIdx+len.

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

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

(Top Tutor) Daniel C.
(997)
School: Cornell University

Studypool has helped 1,244,100 students

## Review from our student for this Answer

FratBro23
Nov 27th, 2013
"Solid work, thanks. "

1831 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