C Program to convert Octal number to Binary numbers

Simple C Program to convert Octal number to Binary numbers

Code:

#include<stdio.h>
#include<conio.h>
int main(){

char octalNumber[50];
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++;
}


getch();
}

Comments

Popular posts from this blog

C program to evaluate Prefix Expression using Stack data structure

Java Program to Implement sorting algorithm using TCP on Server application

C++ program to perform data transformation Min-max and Z score Normalization