This C program, using recursion, finds the binary equivalent of a decimal number entered by the user. Decimal numbers are of base 10 while binary numbers are of base 2.
Here is the source code of the C program to display a linked list in reverse. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Print Binary Equivalent of an Integer using Recursion
int num, bin;
printf("Enter a decimal number: ");
bin = binary_conversion(num);
printf("The binary equivalent of %d is %d\n", num, bin);
int binary_conversion(int num)
if (num == 0)
return (num % 2) + 10 * binary_conversion(num / 2);
$ gcc binary_recr.c -o binary_recr $ a.out Enter a decimal number: 10 The binary equivalent of 10 is 1010
Sanfoundry Global Education & Learning Series – 1000 C Programs.