Even if you simply put this at the end of the code it says segmentation fault. It's because you are using n in your code and then kind of redeclaring it even though its commented out. To check this simple change the variable n in the above commented code to some other variable which you did not use in the code (some thing like "var") then it works.
TLDR : using the variable name again (even though commented out)
Even if you simply put this at the end of the code it says segmentation fault. It's because you are using n in your code and then kind of redeclaring it even though its commented out. To check this simple change the variable n in the above commented code to some other variable which you did not use in the code (some thing like "var") then it works.
TLDR : using the variable name again (even though commented out)