public
anonymous / gist:5147109
Created

  • Download Gist
gistfile1.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#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
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.