Binary to decimal using Command Line Language
It is highly advisable to go through Command Line Arguments Post before even looking at the code. Please study this for TCS and come back to this post later.
#include <stdio.h>
int main(int argc, char *argv[])
{
int num,binary,decimal=0,rem,base=1;
num=atoi(argv[1]);
binary=num;
while(num>0)
{
rem=num%2;
decimal =rem*base;
num=num/10;
base=base*2;
}
printf("%d",decimal);
return 0;
}
Login/Signup to comment
This is wrong program
The statement should be like this
decimal = decimal + rem * base;
command line language