Can anyone provide me a sample code, executing which generates a segmentation falut. need to understand how it works.
If you really want it:
for(int *p ;;) *p = 5;
Good luck with it :P
But I really don't see how you'd understand it better, in programming, you just have to avoid this.
The only thing you really have to understand about this is that you never write some data to random memory.