当前位置:网站首页>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;
}
边栏推荐
- 将childNodes返回的伪数组转化为真数组
- Wechat applet project practice
- LeetCode 第26天
- 实验五 JPEG
- C语言中的字符串
- 读书笔记->统计学】12-02 置信区间的构建-t分布概念简介
- 直播预告 | 开源安全治理模型和工具直播研讨会
- Mysql A left(right) join B on A.id=B. ID and a.age=1 and a left (right) join b on a.id=b id where A.age=1
- Topic domain model
- Celebrity interview | various strange current situations in the open source community -- night sky Book Chen Zili tison
猜你喜欢
随机推荐
数据库基础及安装
剑指Offer | 旋转数组的最小数字
笔者认为,元宇宙与互联网的发展逻辑在某种成都上是截然不同的
云计算或成时代新拐点?从哪些点可以看出?
直播预告 | 开源安全治理模型和工具直播研讨会
老板要我做一个 IP 属地功能,一个开源库搞定!
Qt+VTK+PCL图片转灰度图且以灰度为Y轴显示
Can PHP array subscripts only start from 0
Storage structure and method of graph (I)
PostgreSQL database master-slave deployment master database suspended restore master database
Celebrity interview | various strange current situations in the open source community -- night sky Book Chen Zili tison
y74.第四章 Prometheus大厂监控体系及实战 -- PromQL简介和监控pod资源(五)
Internet traffic scheduling scheme
Worthington对肝细胞分离系统的测试及相关优化方案
图的存储结构及方法(一)
开发者分享|『啃书吧:深度学习与MindSpore实践』第一章
php可不可以拆分数组
Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction
批量可视化目标检测标注框——YOLO格式数据集
c语言十进制数转二进制数









