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.  
  14. for(int i=1;i<=n;i++){
  15.  
  16. for(int j=1;j<=nst;j++)
  17. printf("*");
  18.  
  19. for(int k=1;k<=nsp;k++)
  20. printf(" ");
  21.  
  22. for(int j=1;j<=nst;j++)
  23. printf("*");
  24.  
  25. nst--;
  26. nsp+=2;
  27.  
  28. printf("\n");
  29.  
  30. }
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0.01s 5292KB
stdin
5
stdout
Enter the number of rows: 
********* ****
***   ***
**     **
*       *