fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. printf("Enter the number of rows: \n");
  6. scanf("%d",&n);
  7.  
  8. int nst=n-1;
  9. int nsp=1;
  10.  
  11. for(int r=1;r<=n;r++)
  12. printf("*");
  13. printf("\n");
  14.  
  15. for(int i=1;i<=n;i++){
  16.  
  17. for(int j=1;j<=nst;j++)
  18. printf("*");
  19.  
  20. for(int k=1;k<=nsp;k++)
  21. printf(" ");
  22.  
  23. for(int j=1;j<=nst;j++)
  24. printf("*");
  25.  
  26. nst--;
  27. nsp+=2;
  28.  
  29. printf("\n");
  30.  
  31. }
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5308KB
stdin
5
stdout
Enter the number of rows: 
*****
**** ****
***   ***
**     **
*       *