Source Code:
#include
<stdio.h>
#include<stdlib.h>
void main(int argc,
char const*argv[])
{
long
number, binary, decimal= 0, base = 1, remainder;
number = atoi(argv[1]);
while (number > 0)
{
remainder = number % 10;
decimal = decimal + remainder * base;
number = number / 10 ;
base = base * 2;
}
printf("%ld", decimal);
}
Output:
User Also Seen : Convert Decimal To Binary Number
Thanks and regards,
Tech Bird
Comments