Guest User

Untitled

a guest
Jan 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6.  
  7. int height;
  8. int space;
  9. int hash;
  10.  
  11.  
  12. do
  13. {
  14. printf( "Pyramid Height:" );
  15. height = get_int();
  16. }
  17.  
  18. while ( height <= 0 || height > 23 );
  19.  
  20.  
  21. for ( int i = 0; i < height; i++ )
  22. {
  23.  
  24. for ( space = ( height - 1 - i ); space > 0; space-- )
  25. {
  26. printf( " " );
  27. }
  28.  
  29. for ( hash = 1; hash <= ( i + 1 ); hash++ )
  30. {
  31. printf( "#" );
  32. }
  33.  
  34. printf( " " );
  35.  
  36. for ( hash = 1; hash <= ( i + 1 ); hash++ )
  37. {
  38. printf( "#" );
  39. }
  40.  
  41. printf( "\n" );
  42. }
  43. }
Add Comment
Please, Sign In to add comment