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