Please HELP!! hollow square with diagonals

I do not know how to get the hollow square with diagonals in the middle can someone please help.

***** // <-- this is how it needs to look like
** **
* * *
** **
*****



the code in the bottom is for a square please help me. thanks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

#include <iostream>
using namespace std;

int main()
{
    int x, square, c;
    c = 1;

    cout << "Enter side of a square: ";
    cin >> x;
    square = x * x;

    while ( c <= square ) {
        cout << "*";
        
        if ( c % x == 0 )
            cout << "\n";


        c++;
    }

    cout << endl;
    return 0;
}
Last edited on
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

using namespace std;

int main()
{
    int square = 0;
    
    cout << "Enter side of a square: ";
    cin >> square;
    
   for (int row = 0; row < square; row++)
   {
       for (int column = 0; column < square; column++)
            cout << '*';
            
        cout << endl;
   }
   
   return 0;
}


This is a nother way of doing your square. Yours is not wrong but this way might give you a better insight into how you can control what gets printed (blank or *) and where.
Topic archived. No new replies allowed.