Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int convert(long int n)
- {
- static int decimal;
- static int j;
- if(n==0)
- return decimal;
- if(n%2)
- decimal += pow(2,j++);
- else
- j++;
- convert(n/10);
- }
- int main()
- {
- long int binary;
- printf("Enter the Binary number: ");
- scanf("%ld",&binary);
- printf("The decimal form is %d",convert(binary));
- fflush(stdin);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement