Loops Hackerrank Solution In C