C Program to print Hollow Rectangle in a star pattern
Program
/* Hollow Rectangle */
#include <stdio.h>
void main()
{
int i, j, m, n;
printf("Enter number of rows:\t");
scanf("%d", &m);
printf("Enter number of columns:\t");
scanf("%d", &n);
for(i = 1; i <= m; i++)
{
for(j = 1; j <= n; j++)
{
if(i == 1 || i == m || j == 1 || j == n)
printf("*");
else
printf(" ");
}
printf("\n");
}
}
Output
Enter number of rows: 5
Enter number of columns: 9
*********
* *
* *
* *
*********