Here, I'm giving the solutions, but it doesn't mean you just copy and paste it. You have to give some time to your problems, think-code think-code think-code. Before diving into solution, think one more time.
If you found any other method to solve HackerRank C Problems, you are most Welcome.