Decimal to octal

i have tried to make the logic of this problem but getting unexpected output . please tell me how to correct this code .

You are reinitialising the values of i again and again . Take a differernt variable to get proper result… You can have a look at this for reference https://ide.codingblocks.com/s/257994