C Program Convert Decimal to Octal
Advertisements
Convert Decimal to Octal Program in C
With the help of C Language you can convert any number from decimal to Octal. Decimal number have base 10 and Octal number have base 8.
Decimal Number System
The decimal numeral system (also called base-ten and occasionally called denary) has ten as its base, which, in decimal, is written 10, as is the base in every positional numeral system. It is the numerical base most widely used by modern civilizations
Octal Number System
The octal numeral system, or oct for short, 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 (starting from the right).
Decimal to Octal Conversion Program in C
#include<stdio.h> #include<conio.h> void main() { int no,rem[20],i=0,j; clrscr(); printf("Please Enter any Decimal Number: "); scanf("%d",&no); while(no>0) { rem[i]=no%8; i++; no=no/8; } printf("Octal number is:"); for(j=i-1; j>=0; j--) { printf(" %d",rem[j]); } getch(); }
Output
Please Enter any Decimal Number: 23 Octal number is: 2 7
Google Advertisment