C Online Compiler
Example: C program to print hollow rectangle star pattern
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to print hollow rectangle star pattern #include <stdio.h> int main() { int rows, columns; printf("Enter the number of rows & columns:\n"); scanf("%d%d", &rows, &columns); printf("\n"); if (rows > 0 && columns > 0) { for (int i = 1; i <= rows; i++) { for (int j = 1; j <= columns; j++) { if (i == 1 || i == rows || j == 1 || j == columns) printf("* "); else printf(" "); } printf("\n"); } } return 0; }
4 6
Output
Clear
ADVERTISEMENTS