Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int binary_decimal(char *);
  4. int main(int argc, char **argv)
  5. /* Declare data types*/
  6. {
  7. if (strcmp(argv[1], "dec")) {
  8. if (strcmp(argv[2], "bin")) {
  9. binary_decimal();
  10. }}
  11. }
  12. /* Other if statements for number systems to come*/
  13. int binary_decimal(char *n)
  14. /* Function to convert binary to decimal.*/
  15. {
  16. char bin; int dec = 0;
  17. while (bin != 'n') {
  18. sscanf (argv[3],"%d",&num);
  19. if (bin == '1') dec = dec * 2 + 1;
  20. else if (bin == '0') dec *= 2; }
  21. printf("%dn", dec);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement