当前位置:网站首页>Binary and decimal system of C language
Binary and decimal system of C language
2022-07-02 09:41:00 【FF small confused acridine~】
Binary is a number system widely used in computing technology . Binary data is used 0 and 1 A number represented by two numbers . But in real life , People use the decimal system , It may be related to the fact that humans have ten fingers . So how to realize the conversion between binary and decimal ?
problem :
Input 4 Contains only 0 and 1 The integer of ( Binary number ), Print the decimal equivalent .
Programming requirements :
1、 According to the requirements of the topic, realize the hexadecimal conversion , With the help of printf Function output result ;
2、 Use scanf Function to input data ;
3、 Please output strictly according to the output effect ;( Affect the performance evaluation )
4、 When submitting the code of the task, it is necessary to ensure that it conforms to the industry code specification , You need to indent and wrap as necessary .( Affect the performance evaluation )
Running effect :
Please enter only 4 The binary number of bits :1101
The corresponding decimal number is :13
Please press any key to continue . . .
#include <stdio.h>
int main(void)
{
int number, result, a, b, c, d;
printf(" Please enter only 4 The binary number of bits :");
scanf("%d", &number);
a = number / 1000 ;
b = number / 100 % 10;
c = number / 10 % 10;
d = number % 10;
printf(" The corresponding decimal number is :%d\n", a * 8 + b * 4 + c * 2 + d);
return 0;
}
边栏推荐
- Safety production early warning system software - Download safety production app software
- Memories of a chat
- 保存视频 opencv::VideoWriter
- MySql报错:unblock with mysqladmin flush-hosts
- Chrome browser plug-in fatkun installation and introduction
- Knowledge points are very detailed (code is annotated) number structure (C language) -- Chapter 3, stack and queue
- C语言之分草莓
- kinect dk 获取CV::Mat格式的彩色RGB图像(openpose中使用)
- C语言之做木桶
- Int to string, int to qstring
猜你喜欢
Memories of a chat
web安全与防御
Enterprise level SaaS CRM implementation
Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
Don't look for it. All the necessary plug-ins for Chrome browser are here
Pool de connexion redis personnalisé
在SQL注入中,为什么union联合查询,id必须等于0
个人经历&&博客现状
TD conducts functional simulation with Modelsim
Fragmenttabhost implements the interface of housing loan calculator
随机推荐
2837xd 代码生成——StateFlow(3)
Alibaba / popular JSON parsing open source project fastjson2
JVM instruction mnemonic
互联网API接口幂等设计
上班第一天的报错(Nessus安装winpcap报错)
Bugkuctf-web24 (problem solving ideas and steps)
BugkuCTF-web21(详细解题思路及步骤)
Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
What are the waiting methods of selenium
Off grid control of three-phase inverter - PR control
JDBC回顾
c语言编程题
Safety production early warning system software - Download safety production app software
C语言之最小数
CKEditor 4.10.1 上传图片提示“不正确的服务器响应” 问题解决
Cmake command - Official Document
Customize redis connection pool
Memories of a chat
企业级SaaS CRM实现