大学c语言课教材答案第一章
C语言第一章习题带答案

练习1-1答案选择题1.下列4组字符串中都可以用作C语言程序中的标识符的是( D )。
A.print 3d oodb B.I\m one_half start$itC.Pxq my->book line# D.str_1 Cpp into2.下面的说法正确的是( C )。
A.C程序由符号构成B.C程序由标识符构成C.C程序由函数构成D.C程序由C语句构成3.与十进制数35相等的二进制数是( A )。
A.100011 B.01001 C.100110 D.100101 4.与47值相等的十六进制数是( A )。
A.2F B.215 C.32F D.115 5.(01101)2 + (101101)2的值是( B )。
A.(101010)2 B.(3A)16 C.(2A)16 D.576.将15向左移动2位后的值是( D )。
A.(3C)16 B.(00111100)2 C.(60)10 D.都正确7.将250与5进行按位与的结果是( A )。
A.0 B.1 C.(FF)16 D.(F0)16 8.将(AF)16与(78)16进行按位异或的结果是( A )。
A.(D7)16 B.(28)16 C.(D8)16 D.(27)16 9.将(717)8按位取反的结果是( B )。
A.(110001)2 B.(060)8 C.(60)10 D.都不正确练习2-1答案选择题1.C语言中的简单数据类型包括( B )。
A.整型、实型、逻辑型B.整型、实型、字符型C.整型、字符型、逻辑型D.整型、实型、逻辑型、字符型2.在C语言中,错误的int类型的常数是( A )。
A.32768 B.0 C.037 D.0Xaf3.下列常数中不能作为C的常量的是( D )。
A.0x45 B.2.5e-2 C.3e2 D.05824.设int类型的数据长度为2个字节,则unsigned int类型数据的取值范围是( B )。
大一c语言习题练习及答案

第一章程序设计与C语言1.1 选择题考点:标识符的命名规则(1)只能由字母、数字、下划线构成(2)数字不能作为标识符的开头(3)关键字不能作为标识符选项A中的“-” ,选项B中“[”与“]”不满足(1);选项D中的int为关键字,不满足(3)1.下列正确的标识符是(C)。
A.-a1B.a[i]C.a2_iD.int t2.下列C语言用户标识符中合法的是(B)。
A)3ax B)x C)case D)-e2 E)union选项A中的标识符以数字开头不满足(2);选项C,E均为为关键字,不满足(3);选项D中的“-”不满足(1);3.下列四组选项中,正确的C语言标识符是(C )。
A)%x B)a+b C)a123 D)123选项A中的“%” ,选项B中“+”不满足(1);选项D中的标识符以数字开头不满足(2)4.下列四组字符串中都可以用作C语言程序中的标识符的是(A )。
A、print _3d db8 aBcB、I\am one_half start$it 3paiC、str_1 Cpp pow whileD、Pxq My->book line# His.age选项B中的“\”,”$” ,选项D中“>”,”#”,”.”,”-”不满足(1);选项C中的while为关键字,不满足(3)知识点:简单C语言程序的构成和格式5.在一个C程序中___B___。
A、main函数必须出现在所有函数之前B、main函数可以在任何地方出现C、main函数必须出现在所有函数之后D、main函数必须出现在固定位置6.以下说法中正确的是__D____。
A、#define和printf都是C语句B、#define是C语句,而printf不是C、printf是C语句,但#define不是D、#define和printf都不是C语句7.一个C程序的执行是从(A )。
A本程序的main函数开始,到main函数结束B本程序文件的第一个函数开始,到本程序文件的最后一个函数结束C本程序的main函数开始,到本程序文件的最后一个函数结束D本程序文件的第一个函数开始,到本程序main函数结束8.在C 语言中,每个语句必须以(D )结束。
c语言《程序设计基础》课后习题参考答案与解析

c语言《程序设计基础》课后习题参考答案与解析《程序设计基础》习题参考答案与部分解析第1章 C 语言概述一、填空a) C源程序的基本单位是函数。
b) 一个C程序中至少应包括一个 main函数。
c) 在C语言中,输出操作是有库函数 printf( )函数完成。
二、单选题1、A2、C3、B解析:第1题答案:A 。
因为一个C程序总是从main函数开始执行的,而不论main函数在程序中的位置。
且到main函数结束。
第2题答案:C 。
因为 main函数没有限制必须位于程序的最前面。
C程序书写自由,一行内可写几个语句。
在对一个C 程序进行编译的过程中,无法检查注释当中的拼写错误。
不过C语言本身并没有输入输出语句,输入输出是由函数完成的。
第3题答案:B。
因为一个C语言程序是由若干个函数组成的。
但至少包含一个main 函数,且main函数的位置不限。
三、编程题1、编写一个输出“Welcome to C!”信息的小程序。
解:程序如下#include “stdio.h”main( ){1printf(“Welcome to C!”) ;}2、已知三角形的三边长分别为3,4,5,试用海轮公式编程求其面积。
海伦公式为:S?= ,其中s= (a+b+s)/2 ;解:程序如下#include “math.h”#include “stdio.h”main( ){int a , b , c ; /* a ,b,c 3个整型变量表示三角形的3条边。
*/float s ,s1 ; /* s1作为面积变量,s 作为中间变量是都应该是实形*/a=3 ; b= 4; c=5 ;s= (a+b+c)/2.0 ;s1= sqrt(s*(s-a)*(s-b)*(s-c)); /* sqrt函数完成开平方根功能。
*/printf(“area=%f\n”,s1);}2第2章程序设计基础知识一、单选题1、C2、A3、C4、A5、C6、C7、D8、C9、D 10、A 11、D 12、A 13、C 14、C 15、B A 16、B 17 D解析:1. 答案:C。
昆明理工大学C语言程序设计课后习题答案

昆明理工大学C语言程序设计课后习题答案第1章认识C语言(一)、是非题1.程序是指挥计算机进行各种信息处理任务的一组指令序列。
A.对B.错2.机器语言与硬件平台相关,但汇编语言和硬件平台无关。
A.对B.错3.编译型高级语言明显优于解释型高级语言。
A.对B.错4.C语言把高级语言的基本结构和低级语言的实用性紧密结合起来,不仅适合编写应用软件,而且适于编写系统软件。
A.对B.错5.面向对象的程序设计方法明显优于面向过程的程序设计方法。
A.对B.错6.计算机算法要有一个明确的起点和确定的步骤序列。
A.对B.错7.main函数是C程序的入口,由计算机系统负责调用。
A.对B.错8.在C语言中,同一行上可以写一条或多条语句,但一条语句不能写在多行上。
A.对B.错9.在C语言中,扩展名为.h的文件称为头文件,常用于组织C标准函数库中的函数。
A.对B.错10.注释语句会增加编译结果的复杂性,因此要尽量减少注释语句的数量。
A.对B.错11.声明变量的含义是通知编译系统为变量分配合适大小的存储空间。
A.对B.错12.C语言不允许使用关键字作为变量的名称,但可以使用保留字为变量命名。
A.对B.错13.符号常量提高了程序的可读性,但降低了程序维护的方便性。
A.对B.错14.变量声明把一个具体的标识符名称和计算机内存中的一个特殊的位置联系起来,同时确定了该位置存储的信息类型。
A.对B.错15. C语言允许在同一条语句中定义多个相同类型的变量,其间用分号进行分隔。
A.对B.错16.在ISO/ANSI 1999规定中,允许将变量声明放在程序中的任何位置。
A.对B.错17.不同类型的数据在内存中所占存储单元的大小不同,内部存储方式不同,取值范围不同,甚至能够参与的运算种类也不相同。
A.对B.错18.有符号和无符号整数的区别仅在于对数据最高位的解释不同。
若最高位解释为数据位,则为signed类型;若最高位解释为符号位,则为unsigned类型。
c语言第一章答案(Clanguage1)

c语言第一章答案(C language 1)Chapter 1 basic knowledge of C languageFirst, the multiple-choice question1the answer is AA correct textbook, page 11, line secondB (} can be regarded as a sign of compound statementsThe C main function is not user namedThe D semicolon is the end of the statement. It must be part of the statementTo do this subject requires a thorough understanding of the concepts in the book2the answer is AThe A error textbook, page fourth, describes the user identifier like this 一when naming an identifierThe selection is customized by the user, but cannot be the same as the keyword, so the A option is incorrect, thisSubject to user identifierThe user identifier is an identifier, so it can be underlined, but the underlined character does not belong to the alphabet,Underline one of the numbers. This topic examines the concept of user identifiers.4the answer is BDefine is a predefined identifier, and a predefined identifier can be a user identifier, soDefine can be user ID, if is keyword, and keyword cannot be user identifier,Therefore, if cannot be a user identifier5the answer is DSizeof is the key word, refer to appendix twoNote: 6一13 examines the concept of user identifiers6the answer is DThe D answer begins with number 2 and does not conform to the identifier definition7the answer is C8the answer is DInt is the keyword9the answer is BThe answer A is the key word, the answer C starts with the number, does not conform to the concept, the answer D outThe decimal point is now displayed10the answer is AThe answer A has a decimal point11the answer is CAnswer C begins with numbers12the answer is AB answer, float is the key word,C answer, 3C to number 3 start,D answer in -5dNot one of the letters, numbers, or underscores13the answer is AB the answer is "-max - error”. InC answer, "3COM" begins with letter 3, and "D" in answerInt is a keyword, not a user identifier14the answer is BA answer 15. should not be a bit behind, C answer appears in the comma, D in the letter Bproblem15the answer is BThe last 8 lines of the eighth page of the textbook16the answer is B8 appears in B, and octal can only consist of 0 to 717the answer is DThe answer D begins with 0, not o18the answer is CIn answer A, E is followed by integers and 0. 5 by decimalsIn answer B, E cannot be empty laterIn answer D, E cannot be blank aheadThis topic examines the index representationThere is a problem with 2 in answer A, not decimal formIn answer B, E cannot be blank aheadIn answer D, E cannot be empty laterThis topic examines the index representation20the answer is AB in octal can not appear in the number 8,C in E can not be followed by decimal,D inE behindCan not be empty21the answer is B0.4 of B is decimal, incorrect22the answer is C0.5 of C is decimal, incorrect23the answer is D3. 6-5/2+1. 2+5%2=3. 6-2+1. 2+1=3. 8This topic examines arithmetic operators, noting that integers are divided by integers and that results can only be integers% cannot be used for real type calculations25the answer is DD answer, $does not belong to letters, numbers, underscores26the answer is AA the answer is a comma expression. In theB answer, x+l=y is the assignment expression, and the left is the changeVolume, and this is x=l, and similarly, the answer C is also wrong in x+10, in the D answer,The type conversion is mandatory,Correct is (double) x/1027the answer is AThe subject of this review is where the notes need to be noted, and the specific answers are shown in the middle of the second page of the textbook28the answer is BIn answer A, N2 is not defined. In answer C, you cannot use it before defining f. The answer is DThe middle of E must be an integer29the answer is CThe type of transformation is mandatory, and the k% (int) f is correct30the answer is DThis topic is similar to the textbook sixteenth page example 15, the solution is to seize ++m, 一n, 一m,The value of an expression is the value after the change of the variable, and the value of the n-- expression is the variation of the variable nPrevious value31the answer is BThis topic is the textbook tenth page example 9, the concrete solution sees the textbook, this topic inspects is negativeAn integer is the same as a unsigned positive integer stored in a computer, but not expressedThe same two numbersIn A answer, % operand cannot be real type, 26.8 error, assignment in B answerOperator, the left of the assignment operator must be a variable, so the assignment operator has the wrong 1+2 on the leftWrong, same answer, D error33the answer is CThis topic examines the first point about the addition and decrement operators on the fifteenth page of the textbookThat is only the operation object increment operator is variable, while in C + + (i+1).And i+1 is an expression34the answer is BThis topic examines the integer divided by integer. The result is an integer. In the B answer, the 1/2 result is 0, which leads to the value of the whole expression of 0, which is obviously wrong35the answer is D36the answer is ASee the last tenth lines of the thirteenth page of the textbookSimilarly, the type of aand B is doubleSee textbook ninth, page Two, fill in the blanks textbooks,Ninth pages,the last seventh linestextbooks,third pages,the last fifth lines textbooks,Ninth pages,the last sixth linestextbooks,This topic examines the value of the n++ expression as the value before the change of N, and then increases the value of N by37the answer is BC=a/b+0. 4, c=8/5+0. 4, c=l+0. 4, c=l. 4, because C is int, so the value of n is 1. To do this, you need to read the title carefully 38the answer is D(int) a+b/b= (int) 5. 5+2. 5/2. 5=5+1. 000000-b=6. 00000039the answer is Dseventh pages, the last fifth lines5 textbooks, eighth pages, integer variables, and eleventh page variables6 5+3. 6/2=5+l. 8=6. 8The value of the 7 a++ expression is the value before the change of a, and, of course, a itself is increased by 18 assign 10 to variable B。
C语言答案(删减版)

C语言答案()第一章C语言程序设计基础习题参考答案1-1 冯·诺依曼体系结构的基本原理:五大构成部分:输入、输出、CPU、控制器、存储器;程序存储、自动执行、逻辑判断功能;二进制的信息表示。
1-6 编辑、编译、链接、执行。
1-7 必须有一个主函数,它是程序执行的起点;一个C语言程序由函数构成;每一条可执行语句都必须由分号结束;函数的代码段必须由花括号对括住。
一个函数中的语句组由声明区和可执行语句区两部分构成。
1-8 三个一缩;每遇到一个结构时均缩格,每结束一个结构时回退;缩格格式必须对齐。
1-9 试给出以下问题的程序设计过程描述:1) 求两个数中之最大者。
#include<stdio.h>int main(void){float fA,fB;clrscr();printf("Please input two values(fA,fB)::"); /*输入要比较的两个数fA,fB*/scanf("%f,%f",&fA,&fB); /*格式化输入fA,fB*/if(fA>=fB) printf("the max is %f",fA);if(fA<fB) printf("the max is %f",fB);return 0;} /*main()函数结束*/2) 求三个数中之最大者。
#include<stdio.h>int main(void){float fA,fB,fC,fMax;printf("Please input three values(fA,fB,fC)::");/*fA,fB,fC是输入的3个数,fMax存放最大值*/scanf("%f,%f,%f",&fA,&fB,&fC);fMax=fA;/*假定fA最大*/if(fMax<fB) fMax=fB;if(fMax<fC) fMax=fC;printf("The max is %f\n",fMax);/*输出最大值*/return 0;} /*main()函数结束*/3) 求1+2+3+…+100,即。
C语言程序设计基础第一章习题答案

5、C(参考P9,2.编译)
二、填空题
1、函数
2、.c;.obg;.exe
3、机器语言;汇编语言;高级语言;机器语言;高级语言
4、顺序结构;选择结构;循环结构
5、当型循环;直到型循环
三、问答题
1、答:所谓程序就是一组计算机能够识别和执行的指令;程序设计是指利用计算机解决问题的全过程。
2、答:源程序:用高级语言编写的程序;
目标程序:把源程序翻译成的二进制程序;
可执行程序:把目标程序和与系统的函数库以及其他目标程序连接起来形成的程序。
3、答:参考P4
四、编程题
1、答:
#include”stdio.h”
int main()
{
printf(“Happy new year!\n”);
}
2、答:
#include”stdio.h”;
scanf("%d%d",&a,&b);
if(a<b)printf("min=%d\n",a);
else printf("min=%d\n",b);
}
第一章(P14)
一、选择题
1、B(P14小结中的第三段)
2、D(参考P9,3.链接部分的内容)
3、A(B选项,“{}”除了做可以作为函数体的定界符意外还可以作为一个程序块的分节符等;C选项,不是所有的奇函数可以由用户命名的如”main“函数;D选项,分号是C语句的必要组成部分,是不可缺少的。)
《C语言开发入门教程》—习题答案

《C语言开发入门教程》习题答案第1章初识C语言一、填空题1、汇编语言、高级语言2、。
c3、Stadio、h4、return5、编译、链接二、判断题1、×2、√3、×4、√5、√三、选择题1、A2、B3、C、D4、D5、B四、简答题1、printf(),该函数用于输出一行信息,能够简单理解为向控制台输出文字或符号等。
printf()括号中的内容称为函数的参数,括号内能够看到输出的字符串“Hello, world\n”,其中“\n"表示换行操作,它可不能输出到控制台。
2、注释是对程序的某个功能或者某行代码的解释说明,它只在C语言源文件中有效,在编译时会被编译器忽略、五、编程题1、参考答案#include<stdio、h〉void main(){printf(”我喜爱C语言!");ﻩgetchar(); //等待输入一个字符,起到让运行结果界面暂停}第2章数据类型与运算符一、填空题1、0、0x/0X2、下划线3、原码、反码、补码4、构造类型、空类型5、获取数据字节数二、判断题1、×2、×3、√4、×5、√三、选择题1、A、B、D 2、B 3、B4、C5、D四、简答题1、在C语言中依照运算符进行运算需依照变量的个数能够将运算符分为单目运算符、双目运算符和三目运算符,其区别与示例如下表:2、在进行自增(++)和自减(——)的运算时,假如运算符(++或—-)放在操作数的前面则是先进行自增或自减运算,再进行其他运算。
反之,假如运算符放在操作数的后面则是先进行其他运算再进行自增或自减运算。
五、编程题1、参考答案#include〈stdio、h>void main(){ﻩfloat a = 1。
5, b= 2。
6, h =5;ﻩfloat s;ﻩs= (a +b)*h;ﻩprintf(”梯形的面积为:%、2f\n", s); //%。