Chapter:

Recursive-program-in-c

C Program to Print Binary Equivalent of an Integer using Recursion

Problem Description

This C program, using recursion, finds the binary equivalent of a decimal number entered by the user.

Problem Solution

Decimal numbers are of base 10 while binary numbers are of base 2.

Program/Source Code

#include <stdio.h>

 

int binary_conversion(int);

 

int main()

{

   int num, bin;

 

   printf("Enter a decimal number: ");

   scanf("%d", &num);

   bin = binary_conversion(num);

   printf("The binary equivalent of %d is %d\n", num, bin);

}

 

int binary_conversion(int num)

{

    if (num == 0)

    {

        return 0;

&n....

Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-