Skip to content

Instantly share code, notes, and snippets.

@jcoryalvernaz
Created May 20, 2018 16:44
Show Gist options
  • Save jcoryalvernaz/da2cb4dd21156f5383929799a30a96ed to your computer and use it in GitHub Desktop.
Save jcoryalvernaz/da2cb4dd21156f5383929799a30a96ed 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;
int hashesSecond;
//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; hashes++)
{
printf("#");
}
printf(" ");
for (hashesSecond = 1; hashesSecond <= i; hashesSecond++)
{
printf("#");
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment