Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- int main(void)
- {
- int h;
- int i;
- int hashes;
- int spaces;
- // Lets check the user enter a positive number from 0 to 23
- do
- {
- printf("Height is: ");
- h = get_int();
- }
- while ( h < 0 || h > 23);
- // the loop for building rows
- for ( i = 1; i <= h; i++)
- {
- // the loop for writing spaces
- for ( spaces = h - i; spaces > 0; spaces--)
- {
- printf(" ");
- }
- // the loop for writing hashes
- for ( hashes = i + 1 ; hashes > 0 ; hashes--)
- {
- printf("#");
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement