Lets follow a logical sequence to answer your question.

1.
When are core files are created? When the program does something bad.

2.
What is something bad?? Can be many things, but lets list some issues
- divide by zero
- accessing a bad pointer i.e. a pointer that is not legal

3.
So, when you write a program to do one of the above bad things, you will generate a core dump. Try it out.

Hope that helps.