当前位置:网站首页>C language decimal number to binary number
C language decimal number to binary number
2022-07-23 08:10:00 【Live up to youth and Su】
#include <stdio.h>
#define N 8 // Fixed digits
int main()
{
int arr[N] = {0};// Initialize the array to 0( When the number of digits is not enough , Will output 0 fill )
int i;
int n;
printf(" Please enter an integer :\n");
scanf("%d",&n);
for (i = N-1; i >=0; i--) // Assign values to the array from back to front
{
arr[i] = n % 2;
n /= 2;
}
printf(" This value is converted into binary number and output as (8 position ):");
for (i = 0; i <= N - 1; i++)
printf("%d",arr[i]);
return 0;
}
边栏推荐
- Using private key to connect to server remotely in pycharm
- Solution to the second game of 2022 Hangzhou Electric Multi school league
- Networkx visualizes graphs
- Web资源共享
- Worthington羟基类固醇脱氢酶技术说明及测定方案
- buu web
- uni-app进阶之内嵌应用【day14】
- There are 13 detailed methods for JMeter to view the response of the result tree!
- 主控芯片CSU18M92开发智能体重秤方案
- networkx 对图进行可视化
猜你喜欢
随机推荐
Arduino中断实现上升沿检测,并执行其他函数
Go 语言的 RSA 用秘钥解析JSEncrypt.js 这个库加密的密文失败
TensorRT的插件实战(1)
传统银行票据打印系统几个关键技术点简要分析
使用同一个接口实现不同登录的方式
PostgreSQL database master-slave deployment master database suspended restore master database
将childNodes返回的伪数组转化为真数组
Binary tree (learning daily)
大咖訪談 | 開源社區裏各種奇怪的現狀——夜天之書陳梓立tison
为什么有的人把代码写的如此复杂?
直播预告 | 开源安全治理模型和工具直播研讨会
学习总结 | 真实记录 MindSpore 两日集训营能带给你什么(一)!
Google Earth engine app - a complete map legend app (land use classification of western United States)
使用路由协议配置 IPv6 over IP手动隧道
互联网流量编排方案
Learn these SketchUp skills and improve work efficiency by half
uni-app进阶之内嵌应用【day14】
It can't be true? Nailing has been downloaded. Don't you know you can play like this?
开发者分享|MindSpore Lite 体验,一键实现图像分割
实验七 H.264文件分析









