Advertisement
5_2007-2008 Math #193178

Octal To Binary

Converting

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define MAX 100
main(){
char bin[20];
int dec,temp;
int i=0;
	clrscr();
		printf("Enter octal number: ");
		scanf("%d", &dec);
		temp=dec;
		int a=0;
		do{
			a=temp%8;
			if(a==0){
				bin[i++]='0';
			}else if(a==1){
				bin[i++]='1';
			}
			dec/=8;
			temp=dec;
		}while(dec>0);
		printf("\n");
		printf("Binary value is ");
		for(int j=i;j>=0;--j){
			printf("%c", bin[j]);
		}
	getch();
	return 0;
}
Original Comments (3)
Recovered from Wayback Machine