You are taking three input but your code consider only two.
just because of loop it's just printing 2 times.
with the same value.
for example you entered :
but when it reaches the code:
it's becomes like
And due to for loop :
because the value is 1901.
How to fix ?
so you have to take input inside for loop.
please check this code. it will help you.