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