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