fork(2) download
  1. #include <stdio.h>
  2. //#include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6.  
  7. // get user input and set to variable
  8. printf("Height: \n\n");
  9. int height = 5;//GetInt();
  10.  
  11.  
  12. int i, j, k;
  13. for(i = 0 ; i < height; i++)
  14. {
  15.  
  16. // create n-1 spaces
  17. for(k = (height ); k > (i-1); k--)
  18. {
  19. printf("%c", ' ');
  20. }
  21.  
  22. // create n+1 hash tags
  23. for(j = 0; j < (i+1); j++)
  24. {
  25. printf("#");
  26. }
  27.  
  28. printf("\n");
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
Height: 

      #
     ##
    ###
   ####
  #####