Skip to content

Instantly share code, notes, and snippets.

@sameekapdi
Created September 7, 2017 16:44
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 sameekapdi/b92ff2dd87b9736be37a02bf8805125d to your computer and use it in GitHub Desktop.
Save sameekapdi/b92ff2dd87b9736be37a02bf8805125d to your computer and use it in GitHub Desktop.
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int height;
do
{
printf("Height: ");
height = get_int();
} while (height < 0 || height > 23);
for (int i = 0; i < height; i++)
{
//print spaces for left pyramid
for (int c = 2; c <= height - i; c++)
{
printf(" ");
}
//print hashes for left pyramid
for (int c = 0; c <=i; c++)
{
printf("#");
}
//print gap
printf(" ");
//print right hashes
for (int c = 0; c <=i; c++)
{
printf("#");
}
//print new line
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment