main()
{
int i,c=0,sum=0;
scanf("%d",&i);
while(i>=0)
{
i=i%2;
sum=sum+i*pow(10,c);
i=i/2;
c++
}
printf("%d",sum);
}
OR =)
#include<stdio.h>
#include<conio.h>
void showbits(int h)
{
if(h==1)
printf("%d",h);
else
{
showbits(h/2);
printf("%d",h%2);
}
}
void main()
{
int nu;
void showbits(int h);
clrscr();
printf("Num?");scanf("%d",&nu);
printf("\nBin eq of %d is ",nu);
showbits(nu);
getch();
}
Chat with our AI personalities
#include<stdio.h> #include<stdlib.h> main() { int number,binary[10000],b=0; printf("Enter decimal number "); scanf("%d",&number); printf("\nBinary: "); for(;number;number/=2,b++) binary[b]=number%2; for(b--;b>-1;b--) printf("%d ",binary[b]); }
Each hexadecimal digit (or nybble) is the equivalent of 4 binary digits (or bits) with a decimal value of 0-15. Convert each nybble into (4) binary (digits) and string them together, remembering the conversion of decimal 0-15 to binary: Hex -> Dec -> Binary 0 -> 00 -> 0000 1 -> 01 -> 0001 2 -> 02 -> 0010 3 -> 03 -> 0011 4 -> 04 -> 0100 5 -> 05 -> 0101 6 -> 06 -> 0110 7 -> 07 -> 0111 8 -> 08 -> 1000 9 -> 09 -> 1001 A -> 10 -> 1010 B -> 11 -> 1011 C -> 12 -> 1100 D -> 13 -> 1101 E -> 14 -> 1110 F -> 15 -> 1111 So to convert 0x6AF to binary: 6 -> 0110 A -> 1010 F -> 1111 => 0x6AF = 0110 1010 1111 = 011010101111 (without the spaces showing the hex nybbles)
turn off your pc.
start read a read b c=a-b print c end
k h da 1 . d c m kilo hecto deka meter, liter, gram, etc. (Base) . deci centi milli If you want to convert from centimeters to millimeters, move the decimal one decimal place to the right. King Henry Died By (Base) Drinking Chocolate Milk If you can remember the top or the acronym, you'll never have this problem again.