Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6.     int height;
  7.     do
  8.     {
  9.         //asks user to input height of Mario's pyramid
  10.         printf("Let's make Mario's half-pyramid! Type a number between 1 and 23: \n");
  11.         height=GetInt();
  12.     }
  13.     while(height<0||height>23);
  14.     //generates rows for the pyramid according to user's input
  15.     for(int row_number=0; row_number<height; row_number++)
  16.     {
  17.         //prints empty spaces
  18.         for(int space_number=0; space_number<height-row_number; space_number++)
  19.         {
  20.             printf(" ");
  21.         }
  22.         //prints hash marks
  23.         for(int hash_number=0; hash_number<row_number+2; hash_number++)
  24.         {
  25.             printf("#");
  26.         }
  27.         printf("\n");
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement