➽ Program:-
#include<stdio.h>
int main()
{
int number,
binary_value, decimal_value = 0, base = 1, rem;
printf("Enter a
Binary Number(In 0s and 1s): ");
scanf("%d", &number);
binary_value =
number;
while(number > 0)
{
rem = number % 10;
decimal_value += rem * base;
number = number / 10 ;
base = base * 2;
}
printf("Decimal
Equivalent of %d is %d", binary_value, decimal_value);
return 0;
}
➽ Output:-
Enter a Binary Number(In 0s and 1s): 10111001
Decimal Equivalent of 10111001 is 185
0 Comments
Please do not enter any spam link in the comment section.