Runtime Errors

Output:
  
NZEC: This error denotes “Non-Zero Exit Code” . For C users, this error will be generated if the main() method does not have a return 0 statement. Java /C++ users could generate this error if they throw an exception. Below are the possible reasons of getting NZEC error: 
  - Infinite Recursion or if you run out of stack memory.
 
  - Negative array index is accessed.
 
  - ArrayIndexOutOfBounds Exception.
 
  - StringIndexOutOfBounds Exception.
 
 Below is the program to illustrate the NZEC error: C++
      JavaScript
similar to NZEC ErrorOutput:
  SIGSEGV: This error is the most common error and is known as “ Segmentation Fault “. It is generated when the program tries to access a memory that is not allowed to access or attempts to access a memory location in a way that is not allowed. List of some of the common reasons for segmentation faults are: 
  - Accessing an array out of bounds.
 
  - Dereferencing NULL pointers.
 
  - Dereferencing freed memory.
 
  - Dereferencing uninitialized pointers.
 
  - Incorrect use of the “&” (address of) and “*” (dereferencing) operators.
 
  - Improper formatting specifiers in printf and scanf statements.
 
  - Stack overflow.
 
  - Writing to read-only memory.
 
 Below is the program to illustrate the SIGSEGV error: C++
             Java
                   JavaScript

Output: 
 Ways to avoid Runtime Errors :
  - Avoid using variables that have not been initialized. These may be set to 0 on your system but not on the coding platform.
 
  - Check every single occurrence of an array element and ensure that it is not out of bounds.
 
  - Avoid declaring too much memory. Check for the memory limit specified in the question.
 
  - Avoid declaring too much Stack Memory . Large arrays should be declared globally outside the function.
 
  - Use return as the end statement.
 
  - Avoid referencing free memory or null pointers .