Question:

Write a program in C language to convert a number from decimal to binary.

Show Hint

Recursion is a powerful technique for problems that can be broken down into smaller subproblems, like converting decimal to binary.
Updated On: Oct 8, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Here is a C program that converts a decimal number to its binary equivalent:

Explanation:

  • The function decimalToBinary recursively divides the number by 2 and prints the remainder.
  • The main function reads the decimal number and calls decimalToBinary to print the binary equivalent.

Conclusion:

This program successfully converts a decimal number to binary using recursion in C language.

Was this answer helpful?
0
0