fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n, i, j, space, num;
  5. printf("Enter number of rows: ");
  6. scanf("%d", &n);
  7.  
  8. for(i = 0; i < n; i++) {
  9. // Print spaces
  10. for(space = 0; space < n - i - 1; space++)
  11. printf(" ");
  12.  
  13. num = 1;
  14. for(j = 0; j <= i; j++) {
  15. printf("%4d", num);
  16. num = num * (i - j) / (j + 1);
  17. }
  18. printf("\n");
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Enter number of rows: