Decimal to binary conversion using recursion of an integer

Problem statement
Write a c program to print binary equivalent of an integer number using recursion,your program should not store binary part in any kind of array
#include<stdio.h>
void decbin(int y);
int main()
{
    int in_part;
    float input,flo_part;
    printf("enter the number ");
    scanf("%f",&input);
    in_part=input/1;
    flo_part=input-in_part;
    printf("the binary equivalent is ");
    decbin(in_part);
    return 0;
}
void decbin(int y)
{
     int temp;
     if(y<1)
     {
            return ;
     }
     else
     {
         temp=y%2;
         decbin(y/2);
         printf("%d",temp);
         return ;
     }
}

1 comment:

  1. Hi, TҺere's nօ doսbt that yoսr site could be
    having web browser compatibility issues. Whenever
    I look at your site in Safari, it looks fine bսt when opeոing in IE, it has some overlɑpping issues.
    I merely wanted to provide yοu witɦ a quick heads up!
    Aside from tɦɑt, wonderfսl site!

    Also visit my site: temp

    ReplyDelete