C语言的问题解答(英文的)

来源:百度知道 编辑:UC知道 时间:2024/06/20 01:03:05
高手能不能帮忙翻译一下C语言的题目,并且指点一下应该怎么做,把大概的思路说说就行..谢谢

Write a program to identify the number of bits allocated for a variable of data type “short int”. [Note that your
program may be compiled on different computer systems and it must provide the correct answer on each of these
systems.] You are told that computing system employs 2’s complement notation for storing negative integers.
You may use “unsigned short int” to employ the same number of bits to store only positive numbers.
Your program MUST use only while statements (and break if necessary) for looping. Your program MUST NOT include
any other library files other than stdio.h and math.h.
Call this program positive-negative.c.
Declaration of a short int variable: short int <variable name>;
Declaration of an unsigned short int variable: unsigned short int <variable name>;

写程序计算一个短整型变量的数字位数,注意你的程序需要在不同的计算机系统中都能编译通过且结果正确。计算机系统使用2的补码储存负数,你可以使用无符号短整型在同样的存储长度内只存储正数。
程序中的循环只允许应用while语句,break命令可以用。程序中除了stdio.h和math.h之外不能包括其他库函数。
程序起名为positive-negative.c
短整型变量的声明:short int <变量名>
无符号短整型变量的声明:unsigned short int <变量名>