how to overcome run time errors
It is due to memory leakages, look if you are trying to access an index outside the predefined size of an array i.e. out of bound access.
For ex: if you initialize an array of size 5, arr[5], and if you try to access arr[5] or arr[6] then you will get runtime error(NZEC).
Some more reasons for runtime errors are key and value errors but mainly it is due to out of bound access.