#include<stdio.h>
int main(int argc, char * argv[])
{
int num, binary_val, decimal_val = 0, base = 1, rem;
if(argc!=2)
{
exit(1);
}
num = atoi(argv[1]);
binary_val = num;
while (num > 0)
{
rem = num % 10;
decimal_val = decimal_val + rem * base;
num = num / 10 ;
base = base * 2;
}
printf("Binary number = %d \n", binary_val);
printf("Its equivalent decimal no = %d \n", decimal_val);
return 0;
}
int main(int argc, char * argv[])
{
int num, binary_val, decimal_val = 0, base = 1, rem;
if(argc!=2)
{
exit(1);
}
num = atoi(argv[1]);
binary_val = num;
while (num > 0)
{
rem = num % 10;
decimal_val = decimal_val + rem * base;
num = num / 10 ;
base = base * 2;
}
printf("Binary number = %d \n", binary_val);
printf("Its equivalent decimal no = %d \n", decimal_val);
return 0;
}
0 Comments