Skip to content

Instantly share code, notes, and snippets.

@deeunix
Created September 13, 2020 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeunix/87d6e569b4760d0559465f985c7d3481 to your computer and use it in GitHub Desktop.
Save deeunix/87d6e569b4760d0559465f985c7d3481 to your computer and use it in GitHub Desktop.
cs50 Mario solution
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int height; //declare int variable Height
do
{
height = get_int("Height: ");
}
while (height < 1 || height > 8); //make sure height is not less than 1 or greater than 8
for (int row = 0; row < height; row++) //to print new line as ROW
{
for (int space = height - row - 1; space > 0; space--) //to print SPACE
{
printf(" ");
}
for (int hash = 0; hash < row + 1; hash++) //to print hashes(#)
{
printf("#");
}
printf("\n");
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment