Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- int main(void)
- {
- int height;
- do
- {
- //asks user to input height of Mario's pyramid
- printf("Let's make Mario's half-pyramid! Type a number between 1 and 23: \n");
- height=GetInt();
- }
- while(height<0||height>23);
- //generates rows for the pyramid according to user's input
- for(int row_number=0; row_number<height; row_number++)
- {
- //prints empty spaces
- for(int space_number=0; space_number<height-row_number; space_number++)
- {
- printf(" ");
- }
- //prints hash marks
- for(int hash_number=0; hash_number<row_number+2; hash_number++)
- {
- printf("#");
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement