在C语言中,可以使用printf函数的格式控制符“%b”来以二进制形式输出数字。以下是一个示例代码:
#include <stdio.h>
int main() {
int num = 10;
printf("The binary representation of %d is %b\n", num, num);
return 0;
}
运行该代码,将会输出:
The binary representation of 10 is 1010
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:c语言怎么输出二进制