First printf
will print ab
then \b
will make backspace and print si
so your final print becomes asi
.
Now in last \r
will move the cursor at beginning and prints ha
which will replace first two character and makes final string as hai
(ha
from last statement and i
from earlier result.)