Is the given pattern independent of the value of N

How does this pattern depend upon the value of N.

No, it is not independent
it obviously depends on value of n

i mean the value of n should be 9 in the example given in question

#include using namespace std; int main() { int n; cin>>n; int row, col; for (row = 1; row<=n; row = row + 1){ if (row == 1 or row == n){ for (col = 1; col <= n; col = col + 1){ cout << ‘’; } } else if (row <= (n+1)/2){ for (col = 1; col <= ((n+1)/2)+1-row; col = col + 1){ cout << '’; } for (col = 1; col<= (2row - 3); col = col + 1){ cout << ’ '; } for (col = 1; col <= ((n+1)/2)+1-row; col = col + 1){ cout << '’; } } else if (row > (n+1)/2){ for (col = 1; col <= ((n+1)/2)+1-(n-row+1); col = col + 1){ cout << '’; } for (col = 1; col<= (2(n-row+1) - 3); col = col + 1){ cout << ’ '; } for (col = 1; col <= ((n+1)/2)+1-(n-row+1); col = col + 1){ cout << ‘*’; } } cout << endl; } return 0; }

value of n is given by question
so you have to made your logic according to that

the code is you have pasted is not readable
plz share the link of your code

paste your code at ide.codingblocks.com
and then save and share the link

i have seen your code from chat box

the problem with your code is that for n=5 you have to print 9 lines but you are printing only 5

if question is modified then you also have to modify your solution
so just change n to 2*n-1
your code will work

check modified code below