Contact Learn C
Copy Program Share Program

Program 98:Program Convert Decimal to Octal

Program 98:
#include<stdio.h>
main()
{
int dec,temp,i,j=1,octal=0;
printf("Enter the decimal number : ");
scanf("%d",&dec);
temp=dec;
while(temp!=0)
{
i=temp%8;
octal=octal+(i*j);
temp=temp/8;
j=j*10;
}
printf("Octal number : %d\n",octal);
}

Explanation:

This is same as the previous Program 27 :Convert Decimal to binary except we need to change 2 to 8

 Output:

Convert Decimal to Octal

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide