C Programming
Computer Programming

C Program using function Convert Decimal to Octal Number



Write a Program in C using function Convert Decimal to Octal Number

\* C Program using function Convert Decimal to Octal Number *\

# include < stdio.h >
# include < conio.h >
int   convertDecimalToOctal( int decimalNumber ) ;
int   main( )
{

int decimalNumber ;
printf( " \n Enter a decimal number: " ) ;
scanf( "%d", &decimalNumber ) ;
printf( " The Octal number of decimal number %d is = %d", decimalNumber, convertDecimalToOctal(decimalNumber) ) ;
return 0 ;

}

int   convertDecimalToOctal( int decimalNumber ) ;
{

int octalNumber = 0, i = 1 ;
while ( decimalNumber != 0 )
{
      octalNumber += (decimalNumber % 8) * i ;
      decimalNumber /= 8 ;
      i *= 10 ;
}
return octalNumber ;

}

Output of Program :

Output of C Program using function Convert Decimal to Octal Number