Laynetworks  
Web laynetworks.com Google
Home | Site Map | Tell a friends
Management Tutorials
Download
Tutorials
History
Computer Science
Networking
OS - Linux and Unix
Source Code
Script & Languages
Protocols
Glossary
IGNOU
Quiz
About Us
Contact Us
Feedback
 
Sign up for our Email Newsletter
 
Get Paid for Your Tech Turorials / Tips

 

 

Home > Source Code > C Program to Convert Binary Number to BCD
Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
C Program to Convert Binary Number to BCD
 
C Program to Convert Binary Number to BCD
Contributed By** : Rajesh Mohan
 

main()
{

int Num,N;

int R=0,I=0,J,K,L=1;
int B[100];

clrscr();

printf("Enter the number :");

scanf("%d",&Num);

N=Num;

while(Num>0)

{

R=Num%2;

B[I]=R;

Num=Num/2;

I++;

}

if(I<4)

{

J=I;

for(K=1;K<=4-J;K++)

{

B[I]=0;

I++;
}
}

if(I>4)

{

for(K=0;K<I;K++)

{ if(L==4)

L=1;
else

L++;
}
L--;
if(L<4)
{ for(K=1;K<=4-L;K++)

{
B[I]=0;

I++;

}
}

}

for(L=1,K=I-1;K>=0;K--,L++)

{ printf("%d",B[K]);

if(L==4)

{ printf(" ");

L=0;
}

}

getch();

}

C Program Source Code

TOP
 
Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 
Donation | Useful links | Link to Laynetworks.com | Legal | SharePoint Development
Copyright © 2000-2010 Lay Networks All rights reserved.