Advertisement
Realratnadwip

Hollow Star Rectangle Print

Jun 4th, 2025
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void main()
  5. {
  6.     int row, col, i, j;
  7.  
  8.     printf("This is a simple program to print a hollow rectangle star pattern.\n\n");
  9.     printf("Enter number of rows : ");
  10.     scanf("%d", &row);
  11.     printf("Enter number of columns : ");
  12.     scanf("%d", &col);
  13.  
  14.     for(i = 1; i <= row; i++)
  15.     {
  16.         for(j = 1; j <= col; j++)
  17.         {
  18.             if(i == 1 || i == row || j == 1 || j == col)
  19.             {
  20.                 printf("*");
  21.             }
  22.             else
  23.             {
  24.                 printf(" ");
  25.             }
  26.         }
  27.         printf("\n");
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement