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