how to solve segmentation fault (core dumped) in c code example

Example 1: python segmentation fault (core dumped)

You might be working with a lot of data and your RAM is full

Example 2: Segmentation fault (core dumped)

Core Dump/Segmentation fault is a specific kind of error caused by 
accessing memory that “does not belong to you.” 
In C++ this can be caused by:
~Accessing an address that is freed
~Accessing out of array index bounds
~Stack Overflow
~Dereferencing uninitialized pointer