Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int binary_decimal(char *);
- int main(int argc, char **argv)
- /* Declare data types*/
- {
- if (strcmp(argv[1], "dec")) {
- if (strcmp(argv[2], "bin")) {
- binary_decimal();
- }}
- }
- /* Other if statements for number systems to come*/
- int binary_decimal(char *n)
- /* Function to convert binary to decimal.*/
- {
- char bin; int dec = 0;
- while (bin != 'n') {
- sscanf (argv[3],"%d",&num);
- if (bin == '1') dec = dec * 2 + 1;
- else if (bin == '0') dec *= 2; }
- printf("%dn", dec);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement