C Online Compiler
Example: C program to convert octal Number to binary number
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to convert octal Number to binary number #include <stdio.h> #include <math.h> // It's main function of the program int main() { int decimal_num, octal_num, temp_octal_num, i = 0; long long binary_num; printf("Enter Octal Number: "); scanf("%d", &temp_octal_num); octal_num = temp_octal_num; // Step-1 make conversion octal to decimal while (temp_octal_num != 0) { decimal_num += (temp_octal_num % 10) * pow(8, i); ++i; temp_octal_num /= 10; } i = 1; // Step-2 then make conversion decimal to binary while (decimal_num != 0) { binary_num += (decimal_num % 2) * i; decimal_num /= 2; i *= 10; } // Final output of the program printf("\n%d (Octal Number) = %lld (Binary Number)\n", octal_num, binary_num); return 0; }
150
Output
Clear
ADVERTISEMENTS