Segmentation fault in compiler

https://ide.codingblocks.com/s/457962 . . . .

This solution works on the coding blocks ide but gives and error segmentation fault: 11 on my system using the g++ complier / VS Code

running on vs code as well
may some error at your end
code is correct

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.