// Display a number in octal
void printOct(int n)
{
if(n)
{
// Each octal digit is 3 bits
printOct(n>>3);
// The max value of 3 bits is 7
cout << (n & 7);
}
// If I've got some code that needs to be done when we hit the exit condition, and only
// once, use an else
else
cout << 0;
}
Recursive Convert Number to Octal
Page 1 of 10 Replies - 66 Views - Last Post: 30 October 2008 - 09:28 AM
#1
Recursive Convert Number to Octal
Posted 30 October 2008 - 09:28 AM
Description: Use as a function, or in main if you wishRecursive function to print int into Octal
Page 1 of 1

New Topic/Question
Reply


MultiQuote

|