Skip to content

Commit 18e1a0d

Browse files
Hollow_Square_Pattern.cpp
1 parent 6b28ea6 commit 18e1a0d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Hollow_Square_Pattern.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n;
6+
cin >> n; // Input size of the square
7+
8+
for (int i = 0; i < n; i++) {
9+
for (int j = 0; j < n; j++) {
10+
// Print '*' if we're at the border
11+
if (i == 0 || i == n - 1 || j == 0 || j == n - 1)
12+
cout << "*";
13+
else
14+
cout << " ";
15+
}
16+
cout << endl;
17+
}
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)