lam-tiffany / mario-pyramid

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mario-pyramid

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.

mario-pyramid

Here’s how the program might work if the user inputs 8 when prompted:

$ ./mario
Height of pyramid: 8
       #  #
      ##  ##
     ###  ###
    ####  ####
   #####  #####
  ######  ######
 #######  #######
########  ########

Here’s how the program might work if the user inputs 4 when prompted:

$ ./mario
Height of pyramid: 4
   #  #
  ##  ##
 ###  ###
####  ####

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 of pyramid: -1
Height of pyramid: 0
Height of pyramid: 42
Height of pyramid: 50
Height of pyramid: 4
   #  #
  ##  ##
 ###  ###
####  ####

About

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.


Languages

Language:C 100.0%