➽ Program:-
#include<stdio.h>
#include<math.h>
long
OctalToBinary(int octal_number)
{
int decimal_number = 0, i = 0;
long binary_number = 0;
while(octal_number != 0)
{
decimal_number += (octal_number % 10) * pow(8,i);
i++;
octal_number = octal_number / 10;
}
i = 1;
while(decimal_number != 0)
{
binary_number += (decimal_number % 2) * i;
decimal_number = decimal_number / 2;
i = i * 10;
}
return binary_number;
}
int
main()
{
int octal_number;
printf("Enter an Octal Number:
");
scanf("%d", &octal_number);
printf("Binary number is %ld",
OctalToBinary(octal_number));
return 0;
}
➽ Output:-
0 Comments
Please do not enter any spam link in the comment section.