fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int num, i, y;
  7.  
  8. printf("Enter a number for generating the pyramid:\n");
  9. scanf("%d", &num);
  10.  
  11. for (y = 0; y <= num; y++)
  12. {
  13. for (i = 0; i < num - y; i++)
  14. {
  15. printf(" ");
  16. }
  17.  
  18. for (i = -y; i <= y; i++)
  19. {
  20. printf("%3d", abs(i));
  21. }
  22.  
  23. printf("\n");
  24. }
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Enter a number for generating the pyramid:
  0