Decimal to Octal in C - C Program to Convert Decimal to Octal



 c program to convert decimal to octal

Learn C - C tutorial - c program to convert decimal to octal - C examples - C programs

C Program to Convert Decimal to Octal

  • This is the program for converting the input decimal number to an octal number.
  • The octal number is the base-8 number system, and uses the digits 0 to 7.
  • Octal numerals can be made from binary numerals by grouping consecutive binary digits into groups of three.
 c program to convert decimal to octal

Learn C - C tutorial - c program to convert decimal 2 octal - C examples - C programs

Sample Code

#include<stdio.h>
void main()
{
    long int n=9,n1,m=1,rem,ans=0;
    printf("\nDecimal No : 9");
    n1=n;
    while(n > 0)
    {
        rem=n%8;
        ans=(rem*m)+ans;
        n=n/8;
        m=m*10;
    }
    printf("\nYour Decimal No is : %ld",n1);
    printf("\nConvert into Octal No is : %ld",ans);
}

Output

Decimal No : 9
Your Decimal No is : 9
Convert into Octal No is : 11


View More Quick Examples


Related Searches to Decimal to Octal in C - C Program to Convert Decimal to Octal