Description:
Decimal Numbers:
Decimal numbers has a radix 10. Decimal numbers use a combination of 0,1,2,3,4,5,6,7,8,9.
Octal Numbers:
Octal numbers has a radix of 8. Octal numbers use a combination of 0,1,2,3,4,5,6,7
Conversion from decimal number system to octal number system can be done by factorize the decimal number by 8.
Decimal Numbers:
Decimal numbers has a radix 10. Decimal numbers use a combination of 0,1,2,3,4,5,6,7,8,9.
Octal Numbers:
Octal numbers has a radix of 8. Octal numbers use a combination of 0,1,2,3,4,5,6,7
Conversion from decimal number system to octal number system can be done by factorize the decimal number by 8.
Source Code:
/*
Decimal to Octal Conversion
Author: sourcecodesonline.blogspot.com
*/
int main(void)
{ long dec_no,oct_no=0,iter=1;
printf("\n\t\t\tDecimal to Octal Conversion");
printf("\n\tEnter the decimal number :");
scanf("%ld",&dec_no);
while(dec_no>7)
{
oct_no=(dec_no%8)*iter+oct_no;
iter*=10;
dec_no/=8;
}
oct_no=dec_no*iter+oct_no;
printf("\nOctal equivalent is %ld",oct_no);
}
Decimal to Octal Conversion
Author: sourcecodesonline.blogspot.com
*/
int main(void)
{ long dec_no,oct_no=0,iter=1;
printf("\n\t\t\tDecimal to Octal Conversion");
printf("\n\tEnter the decimal number :");
scanf("%ld",&dec_no);
while(dec_no>7)
{
oct_no=(dec_no%8)*iter+oct_no;
iter*=10;
dec_no/=8;
}
oct_no=dec_no*iter+oct_no;
printf("\nOctal equivalent is %ld",oct_no);
}
EmoticonEmoticon