Decimal to octal

Sie why we used String
in this code “https://ide.codingblocks.com/s/322966

@lokeshverma764 Bro you can also use int here, no worries.
You can check the code with string below -

public static int decimalToOctal(int n){

        int ans = 0;
        int mult = 1;

        while(n != 0){

            int rem = n % 8;

            ans = ans + rem * mult;
            mult = mult * 10;
            n = n / 8;
        }

        return ans;

    }

Bro dry run this code for small input and lemme know if you have any doubt else close the doubt by marking it resolved.
Happy coding!