#include <stdio.h>
#include <conio.h>
long DecToBin(int); //declaration
int main(){
long BinNo;
int DecNo;
printf("Enter any decimal number: ");
scanf("%d",&DecNo);
BinNo = DecToBin(DecNo);
printf("Binary value is: %ld", BinNo);
getch();
}
//definition
long DecToBin(int DecNo)
{
static long BinNo,remainder,factor = 1;
if(DecNo != 0)
{
remainder = DecNo % 2;
BinNo = BinNo + remainder * factor;
factor = factor * 10;
DecToBin(DecNo / 2);
}
return BinNo;
}
#include <conio.h>
long DecToBin(int); //declaration
int main(){
long BinNo;
int DecNo;
printf("Enter any decimal number: ");
scanf("%d",&DecNo);
BinNo = DecToBin(DecNo);
printf("Binary value is: %ld", BinNo);
getch();
}
//definition
long DecToBin(int DecNo)
{
static long BinNo,remainder,factor = 1;
if(DecNo != 0)
{
remainder = DecNo % 2;
BinNo = BinNo + remainder * factor;
factor = factor * 10;
DecToBin(DecNo / 2);
}
return BinNo;
}