
Toward the beginning of World 1-1 in NintendoΓÇÖs Super Mario Brothers, Mario must hop over adjacent pyramids of blocks, per the below.
LetΓÇÖs recreate those pyramids in C, albeit in text, using hashes (#) for bricks, a la the below. Each hash is a bit taller than it is wide, so the pyramids themselves are also be taller than they are wide.
# #
## ##
### ###
#### ####
The program weΓÇÖll write will be called mario. And letΓÇÖs allow the user to decide just how tall the pyramids should be by first prompting them for a positive integer between, say, 1 and 8, inclusive.
HereΓÇÖs how the program might work if the user inputs 4 when prompted:
$ ./mario
Height: 4
# #
## ##
### ###
#### ####
HereΓÇÖs how the program might work if the user inputs 2 when prompted:
$ ./mario
Height: 2
# #
## ##
And hereΓÇÖs how the program might work if the user inputs 1 when prompted:
$ ./mario
Height: 1
# #
If the user doesnΓÇÖt, in fact, input a positive integer between 1 and 8, inclusive, when prompted, the program should re-prompt the user until they cooperate:
$ ./mario
Height: -1
Height: 0
Height: 42
Height: 50
Height: 4
# #
## ##
### ###
#### ####
Notice that width of the ΓÇ£gapΓÇ¥ between adjacent pyramids is equal to the width of two hashes, irrespective of the pyramidsΓÇÖ heights.
———————————————————————————
How to Test Your Code
Does your code work as prescribed when you input
-1 (or other negative numbers)?
0?
1 through 8?
9 or other positive numbers?
letters or words?
no input at all, when you only hit Enter?
