Convert Decimal Number To Octal

Categories: Java Java Programming & Coding

package r4r.in;


public class ConvertDecimalNumberToOctal {


public static void main(String[] args) {

//Convert Decimal Number To Octal

System.out.println(decimalToOct(10));

}


static int oct = 0;

static int temp = 1;


private static int decimalToOct(int n) {

if (n != 0) {

oct = oct + n % 8 * temp;

temp = temp * 10;

decimalToOct(n / 8);

} else return 0;

return oct;


}

}


R4R.in Team
The content on R4R.in website is created by expert teams.
|| Blockchain || Cisco CCNA || Selenium || Internet security || Thermostat || Fashion || Online Games || Working From Home(WFH) || COVID-19 || Games || Cryptocurrency || Digital economy || Property || Sundarban National Park || NEET Course || Investment || Java || Inverter battery || PDF Drive || Online Library || Yoga || Career || Sports || SEO || Software Engineering || APPs || Digital Marketing || Certified True Copy || Mobiles || Software Testing || Books || TAX || Foreign Currency || AutoCAD || Online Course || Machine || Python || Banks || Bitcoin || Education || German Language || Festivals || Health ||