#include<stdio.h> #define MAX 1000 int main(){ char octalNumber[MAX]; long int i=0; printf("Enter any octal number: "); scanf("%s",octalNumber); printf("Equivalent binary value: "); while(octalNumber[i]){ switch(octalNumber[i]){ case '0': printf("000"); break; case '1': printf("001"); break; case '2': printf("010"); break; case '3': printf("011"); break; case '4': printf("100"); break; case '5': printf("101"); break; case '6': printf("110"); break; case '7': printf("111"); break; default: printf("\nInvalid octal digit %c ",octalNumber[i]); return 0; } i++; } return 0; }
Filled Under
C
C program to convert binary to octal
Related:

Convert numbers to roman numerals in c

C code for fractional binary to decimal converter

C code for product of two binary numbers

C code for sum of two binary numbers:

How to convert large binary number to hexadecimal

C code for binary to decimal conversion

C code for how to convert large binary to octal

C program to convert binary to octal
Subscribe to:
Post Comments (Atom)