Binary to decimal using Command Line Language

C Programming Language Command Line Arguments (Article) Command Line Arguments (Program)

460

Program:

#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 = decimal + rem*base;
        num=num/10;
        base=base*2;
    }
    
printf("%d",decimal);
return 0;
}

Output:

1010

10

Explanation:

Nope

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.