What is the error in the code

#include
using namespace std;

int main()
{
int i, j, n;

cin>>n;


for(i=1; i<=n; i++)
{

    for(j=1; j<=n; j++)
    {
        if(i==1 || i==n||j==1||j==n||j==i||j==n-i+1)
        {

        cout<<"*";
        }
        else
        {
            cout<<" ";
        }
    }

    cout<<"\n";
}

return 0;

}

What you are doing is creating a box and then creating its diagonals.
Whereas we need to create box with * and a diamond in it with space. To create space you need to increase the spaces in each line till you reach mid height, then decrease space in each line. (Focus on mid height and width to keep track of spaces.)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.