Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Using C language array knowledge to find: input an unsigned short integer and output its corresponding binary.
Using C language array knowledge to find: input an unsigned short integer and output its corresponding binary.
By bit operation, short integer 16 bits, shift and 1 one by one to get whether the bit is 0 or 1.

# include & ltstdio.h & gt

int main(void)

{

Unsigned short value;

int I;

Printf ("input value:");

Scanf("%hu ",& value);

for(I = 15; I>= 0; I-) {

Printf("%d ",(value & gt& gtI) and amp0x1);

}

puts(" ");

Returns 0;

}