C Program to Convert Binary Number to Octal
In this program we will convert Binary Number into Octal
- //C program to convert octal to decimal
- #include <stdio.h>
- #include <math.h>
- long long convertOctalToDecimal(int octnum);
- int main()
- {
- int octnum;
- printf("Enter an octal number: ");
- scanf("%d", &octnum);
- printf("%d in octal = %d in decimal", octnum, convertOctalToDecimal(octnum));
- return 0;
- }
- long long convertOctalToDecimal(int octnum)
- {
- int decinum = 0, i = 0;
- while(octnum != 0)
- {
- decinum += (octnum%10) * pow(8,i);
- ++i;
- octnum/=10;
- }
- i = 1;
- return decinum;
- }
Output

Solution not working or have any suggestions? Please send an email to [email protected]
Download Android App