C Program to convert decimal to binary

0
3
digitalample eye
Write a c program to convert decimal number to binary number.
C Program to convert decimal to binary.
C program for decimal and binary conversion.

/*Program to convert decimal to binary*/
#include<stdio.h>
#include<conio.h>
int bin(int x);
void main()
{
int x,binary;
printf("Enter Decimal Number:");
scanf("%d",&x);
binary=bin(x);
printf("The Binary number is %d",binary);
getch();
}
int bin(int x)
{
int q,r;
if(x==0)
return;
q=x/2;
r=x%2;
bin(q);
printf("%d",r);
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here