Program in C to decimal to binary conversion

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
            int no,r,sum=0,i=0;
            clrscr();
            printf(“\nenter the number\n”);
            scanf(“%d”,&no);
            while(no>0)
            {
                        r=no%2;
                        sum=sum+pow(10,i)*r;
                        no=no/2;
                        i++;
            }
            printf(“\nThe binary value is %d”,sum);
            getch();
}


Post a Comment