please guys, i'm never really good at this and the deadline for my project is coming up fast, a little help please..?thank you in advance!
Can you type a C lang. (preferrably turbo C) program that can convert decimal numbers to binary and vice versa
#include %26lt;stdio.h%26gt;
main()
{
int number;
int count=0;
int i;
char binary[20];
printf("\nEnter a Decimal number");
scanf("%d", %26amp;number);
do
{
binary[count++] = (char)(48+(number % 2));
number /= 2;
}
while(number %26gt; 1 %26amp;%26amp; count %26lt; 20);
binary[count++] = (char) (48 + number);
binary[count] = '\0';
for(i=count;i%26gt;=0;i--)
printf("%c", binary[i]);
printf("\n");
}
Tht shud work for decimal to binary. i will try and post the reverse asap..
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment