Binary To Decimal
#include
#include
int main()
{
printf("Convert Binary number to Decimal number\n");
int num;
printf("Please inter your binary:");
scanf("%d",&num);
int dec_value= 0;
int base= 1;
int temp= num;
while (temp){
int last_digit= temp % 10;
temp= temp / 10;
dec_value +=last_digit*base;
base= base* 2;
}
printf("\nThe result of Decimal number is = %d\n",dec_value);
return 0;
}
Result output
0 Comments