Question: C Language Create the two functions used in the main below that would result in the given sample run. You should write complete function definitions.
C Language
Create the two functions used in the main below that would result in the given sample run. You should write complete function definitions.
enter_guest_totals() takes two parameters: the first is a pointer (5 points), the second is the size of the array all_people(1 point). In this function, a user types in the number of guests in each room (a room is an element of the array passed in as the first parameter-see sample run) (8 points). YOU MUST USE POINTER ARITHMETIC OR YOU RECEIVE NO CREDIT FOR THE FUNCTION. It should not return anything (1 point).
find_guests() takes three parameters: the first is a pointer(5 points), the second is the size of the array all_people (1 point), and the third is the max number of guests that room amounts should not exceed(1 point). The function should go through all_people and output any room that has guests over the max number(5 points), (along with the amount over(7 points) -see sample run). It should return the total number of guests that go over the max in the rooms(1 point).
int main(void)
{ int all_people[7]; enter_guest_totals(all_people, 7); int total=find_guests(all_people,7,7); /*the value of total should be 17 in the sample run below*/
}
Sample Run:
Enter guests in room 1: 10 /*output from the enter_guest_totals function*/ Enter guests in room 2: 8 /*output from the enter_guest_totals function*/ Enter guests in room 3: 7 /*output from the enter_guest_totals function*/ Enter guests in room 4: 9 /*output from the enter_guest_totals function*/ Enter guests in room 5: 7 /*output from the enter_guest_totals function*/ Enter guests in room 6: 0 /*output from the enter_guest_totals function*/ Enter guests in room 7: 18 /*output from the enter_guest_totals function*/
Room 1 has 3 guest(s) over 7 /*output from the find_guests function*/ Room 2 has 1 guest(s) over 7 /*output from the find_guests function*/ Room 4 has 2 guest(s) over 7 /*output from the find_guests function*/ Room 7 has 11 guest(s) over 7 /*output from the find_guests function*/
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
