fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int row,col,i,j;
  6. printf("enter the value of col and row\n");
  7. scanf("%d%d",&row,&col);
  8. for(i = 0; i < row; i++)
  9. {
  10. for(j = 0; j < col; j++)
  11. {
  12. if(i==j )
  13. {
  14. printf("*");
  15. }
  16. else if(i+j == col/2-2 && i < col/2-3 || i+j == col/2 && i < col/2-2)
  17. {
  18. printf("*");
  19. }
  20. else if(i+j == col/2+2 && i <= col/2-2 || i+j == col/2+4 && i <= col/2-1)
  21. {
  22. printf("*");
  23. }
  24. else
  25. {
  26. printf(" ");
  27. }
  28. }
  29. printf("\n");
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5352KB
stdin
5 9
stdout
enter the value of col and row
* * * * *
 * * * * 
  * * *  
   * *   
    *