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:
    1. Infinite Recursion or if you run out of stack memory.
    2. Negative array index is accessed.
    3. ArrayIndexOutOfBounds Exception.
    4. StringIndexOutOfBounds Exception.
    Below is the program to illustrate the NZEC error: C++

          JavaScript
    Output:
  • 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:
    1. Accessing an array out of bounds.
    2. Dereferencing NULL pointers.
    3. Dereferencing freed memory.
    4. Dereferencing uninitialized pointers.
    5. Incorrect use of the “&” (address of) and “*” (dereferencing) operators.
    6. Improper formatting specifiers in printf and scanf statements.
    7. Stack overflow.
    8. Writing to read-only memory.
    Below is the program to illustrate the SIGSEGV error: C++
                 Java
                       JavaScript

    Output:

    Ways to avoid Runtime Errors :