Hacking with conversions of decimal and binary

$./app Sign detection [1] Power of two [2] Counting No. of bits set [3] Set or clear bits without branching[4] Find maximum value[5] Finding least common multiple[6] Finding the greatest commom divisor[7] Finding if a number is an Armstrong number or not[8] Finding if a given number is prime number[9] Finding the number of twin …

How to write an algorithm to do a binary to decimal conversion ?

/* part of work copied from http://www.sanfoundry.com/c-program-binary-number-into-decimal/ */ #include <stdio.h> btd() { int num, binary_val, decimal_val = 0, base = 1, rem; printf(“Enter a binary number : “); scanf(“%d”,&num); binary_val = num; while ( num > 0 ) { rem = num % 10; decimal_val = decimal_val + rem * base; num = num / …