C Programming Code Examples C > Conversions Code Examples Convert a Number Decimal System to Binary System using Recursion Convert a Number Decimal System to Binary System using Recursion The following C program using recursion finds a binary equivalent of a decimal number entered by the user. The user has to enter a decimal which has a base 10 and this program evaluates the binary equivalent of that decimal number with base 2. /* C Program to Convert a Number Decimal System to Binary System using Recursion */ #include <stdio.h> int convert(int); int main() { int numberdec, bin; printf("Enter a decimal number: "); scanf("%d", &numberdec); bin = convert(numberdec); printf("The binary equivalent of %d is %d.\n", numberdec, bin); return 0; } int convert(int numberdec) { if (numberdec == 0) { return 0; } else { return (numberdec % 2 + 10 * convert(numberdec / 2)); } }