Skip to content

Instantly share code, notes, and snippets.

@jcoryalvernaz
Created May 20, 2018 16:22
Show Gist options
  • Save jcoryalvernaz/f98e730e9ed0784b7be15384e9df2c7c to your computer and use it in GitHub Desktop.
Save jcoryalvernaz/f98e730e9ed0784b7be15384e9df2c7c to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <cs50.h>
int main(void)
{
//Make variables for height, spaces, and hashes
int height;
int spaces;
int hashes;
//Prompt user for height
do
{
height = get_int("Height: ");
}
//Set conditions
while (height < 0 || height > 23);
//Set rows
for (int i = 1; i <= height; i++)
{
//Set columns of spaces
for (spaces = (height - i); spaces > 0; spaces--)
{
printf(" ");
}
//Set columns of hashes
for (hashes = 1; hashes <= (i + 1); hashes++)
{
printf("#");
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment