Home › Forums › C Programming › base conversion › Re: base conversion
March 13, 2008 at 11:24 pm
#3264
yeswanth
Participant
A program to convert a decimal number to its equivalent binary number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <stdio.h><br /> #include <conio.h><br /> void main()<br /> {<br /> unsigned long dec;<br /> int a[25],c=0,i;<br /> clrscr();<br /> printf("nENTER A DECIMAL NUMBER: ");<br /> scanf("%lu",&dec);<br /> printf("n%lu IN BINARY FORMAT: ",dec);<br /> while(dec>0)<br /> {<br /> a[c]=dec%2;<br /> dec=dec/2;<br /> c++;<br /> }<br /> for(i=c-1;i>=0;i--)<br /> printf("%d",a);<br /> getch();<br /> } |