Skip to content

Instantly share code, notes, and snippets.

Created March 12, 2013 21: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 anonymous/5147109 to your computer and use it in GitHub Desktop.
Save anonymous/5147109 to your computer and use it in GitHub Desktop.
#include <cs50.h>
#include <stdio.h>
int main();
int height;
// user input first
{
do
{
printf("How tall do you want the pyramid?");
int height = GetInt();
}
while ( height <= 0 || height > 23 );
int i = 0;
for(i = 0; i <= height; i++)
{
//declare hash initialization
int hash = i - 1;
while (hash >= 0 && hash <= height) // declare hash condition
{
printf("#");
hash++;
} //declare hash update
//declare space initialization
int space = i - 1;
while (space >= 0 && space <= height) // declare space condition
{
printf(" ");
space--; // declare space update
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment