Question: Before we start developing the Boxed l n game, let's design a simple text - version of a box. A box should be rectangular,
Before we start developing the "Boxed game, let's design a simple textversion of a box. A box should be rectangular, and it should have some marking at the exact center position, so that the person pushing the box knows where to push!
For this task, you must define a function called MakeBox which takes three inputs: a string into which the characters will be stored, the width of the box an integer and the height of the box also an integer The MakeBox function should generate a string representing the box. A box will simply be represented as a rectangle where the hash character # is used to denote the edges. In addition, the exact center of the box must be denoted using the character X to help the person push the box in the correct place
If the width and height of the box are both odd numbers, then there will be a single center position which can be denoted with a single X If the width and the height are both even numbers, then the center position will have to be denoted with a small square of four X characters. If only one of the width or height is an odd number, and the other is an even number, then two characters will be needed to denote the center position. The examples below illustrate these three possibilities:
tabletable###### ## X ## ############ # # # XX # # XX # # # ########### # # # X # # X # # # #####A box this will have a single center positionA x box this will have four center positionsA row, column box this will have two center positions
Note: the length of the output string will be exactly width height characters. This is because there is a single new line character appearing at the end of each line including the last line
For Task One, you must define a function called MakeBox:
void MakeBox char design int width, int height
You can assume that both width and height will be at least Note, the smallest box size for which you will need to include the center position is if the width or height is or less, it is not possible to include the center position so there will be no X characters in the string in that case Need C launguanguage code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
