Getting segementation fault

please look at the journeyToMoon() function, rest of the code has been pre-generated by hackerrank.

soln: https://ide.codingblocks.com/s/259767