Question: To create a C program for managing hotel room occupancy using a two - dimensional array, follow these steps: 1 . Declare and initialize the

To create a C program for managing hotel room occupancy using a two-dimensional array, follow these steps: 1. Declare and initialize the two-dimensional array: - Declare an array named "hotel" with 3 rows and 5 columns. - Implement the `initHotel` function to assign 0 to each element of the array. 2. Create a menu function: - Implement a function called `menu` that displays the available choices (add occupant, remove occupant, display occupancy, quit).- Collect the user's choice and return it as an integer. 3. Process the user's choice: - Implement the `processChoice` function that takes the user's choice and the hotel array as parameters. - Use a switch statement to execute different actions based on the user's choice: - If the choice is 1, call the `addOccupant` function and pass the hotel array as a parameter. - If the choice is 2, call the `removeOccupant` function and pass the hotel array as a parameter. - If the choice is 3, call the `displayHotelSetup` function and pass the hotel array as a parameter. - For any other choice, display an invalid choice message. 4. Implement the `addOccupant` function: - Prompt the user for a floor number between 0 and 2.- If the number is out of bounds, display an appropriate message. - Otherwise, prompt the user for a room number between 0 and 4.- If the number is out of bounds, display an appropriate message. - If the room is already occupied, display a message indicating that. - Otherwise, ask the user for the number of occupants. - If the number is less than or equal to 0 or bigger than 5, display an invalid number of occupants message. - Assign the number of occupants to the corresponding element in the hotel array. 5. Implement the `removeOccupant` function: - Prompt the user for a floor number between 0 and 2.- If the number is out of bounds, display an appropriate message. - Otherwise, prompt the user for a room number between 0 and 4.- If the number is out of bounds, display an appropriate message. - Set the corresponding element in the hotel array to 0 to indicate that the room is now unoccupied. 6. Implement the `displayHotelSetup` function: - Display the contents of the hotel array in the desired format. - Use nested loops to iterate through the array, starting with the highest floor and going down to the ground floor. - Within each floor, display the rooms from left to right.

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!