Not able to find the logic of last inner spaces.
problem in line no.38 of the code https://ide.codingblocks.com/s/104546
Doublesided pattern
@Ajitverma1503
Thank you for pointing out the exact line to look for, it was helpful.
Modify line no.38 to this
for(int space=1;space<=n-d;space++)
i.e. change the loop condition and you will see that your code works perfectly.