The problem seems to be the
for loop. Your program accepts a value for
a as an input, but then as soon as the loop begins, it resets the value of
a to 0 (
for (a = 0;...
Therefore it’s looping 10 times, and on each loop
a will have a different value, starting from 0 and ending at 9. This means that all of your
if statements will get hit at some point in the execution, generally one on each of the loops round the
To get your expected behaviour ” input of 5…and i just want it to print five”, simply remove the
for loop from your code.