decimal to octal recursion Algorithm

Positional notation (or place-value notation, or positional numeral system) denotes normally the extension to any base of the Hindu – In modern positional systems, such as the decimal system, the position of the digit means that its value must be multiply by some value: in 555, the three identical symbols represent five hundreds, five tens, and five units, respectively, due to their different positions in the digit string. Some of those pro-decimal attempts — such as decimal time and the decimal calendar — were unsuccessful. count rods and most abacuses have been used to represent numbers in a positional numeral system. Before positional notation became standard, simple additive systems (sign-value notation) such as Roman numerals were used, and accountants in ancient Rome and during the center age used the abacus or stone counters to do arithmetical.
//Program to convert decimal number to octal (Using Reccursion)
//This program only works for integer decimals
//Created by Aromal Anil

#include <stdio.h>
int decimal_to_octal(int decimal)
{
  if( (decimal<8) && (decimal>0) )
  {
    return decimal;
  }
  else if(decimal==0)
  {
    return 0;
  }
  else
  {
    return ( (decimal_to_octal(decimal/8)*10) + decimal%8 );
  }
}
void main()
{
  int octalNumber,decimalNumber;
  printf("\nEnter your decimal number : ");
  scanf("%d",&decimalNumber);
  octalNumber = decimal_to_octal(decimalNumber);
  printf("\nThe octal of %d is : %d" ,decimalNumber,octalNumber);
}

LANGUAGE:

DARK MODE: