1#include <iostream>
2using namespace std;
3int main()
4{
5 int row, col;
6 cout << "Enter number of rows and columns to create a hollow rectangle: ";
7 cin >> row >> col;
8
9 for (int i = 1; i <= row; i++)
10 {
11 for (int j = 1; j <= col; j++)
12 {
13 if (i == 1 || i == row || j == 1 || j == col) // you can either use a single loop or use elseif with it.
14 {
15 cout << "*";
16 }
17 // else if (j == 1 || j == col)
18 // {
19 // cout << "*";
20 // }
21 else
22 {
23 cout << " ";
24 }
25 }
26 cout << endl;
27 }
28
29 return 0;
30}
31