Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int binary_decimal(int n);
- int decimal_binary(int n);
- int main()
- {
- int n,number;
- scanf("%d", &n);
- number = decimal_binary(n);
- printf("%d",number);
- return 0;
- }
- int decimal_binary(int n) /* Function to convert decimal to binary.*/
- {
- int rem, i=1, binary=0;
- while (n!=0)
- {
- rem=n%2;
- n/=2;
- binary+=rem*i;
- i*=10;
- }
- return binary;
- }
Advertisement
Add Comment
Please, Sign In to add comment