Can't understand problem with my solution

When I run the solution with various test-cases on my computer, it provides correct answer but gives error (Segmentation fault) when I run the same solution on codingBlocks.

Can someone tell me what is the problem in my solution ?