C Programming Code Examples C > Conversions Code Examples This program takes a octal number as input and converts it into binary. This program takes a octal number as input and converts it into binary. Take a octal number as input. Print the binary value of each digit of a octal number. Use switch statement and while loop to do this. #include <stdio.h> #define MAX 1000 int main() { char octalnumber[MAX]; long 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("\n Invalid octal digit %c ", octalnumber[i]); return 0; } i++; } return 0; } Take a octal number as input and store it in the array octalnumber. Using switch statement access each digit of a octal number and print its equivalent binary value in a 3 bit fashion. For example: for 0, print its binary value as 000. Do step 2 under a while loop. Exit.