昆明理工大学C语言复习资料docx文档格式.docx
《昆明理工大学C语言复习资料docx文档格式.docx》由会员分享,可在线阅读,更多相关《昆明理工大学C语言复习资料docx文档格式.docx(28页珍藏版)》请在冰豆网上搜索。

primf(“%cT;
a);
iswrong.(辛昔)
2)Supposedeclaration:
inta;
floatx,y;
thentheresultdatatypeofexpression:
x+a%3*(int)(x+y)%2/4isfloat.
3)Thedatatypeofexpression:
18/4*sqrt(4.0)isfloat.(错)
字符的ASCII值及其合理应用
chara;
thenexpression:
^=^5+9^iscorrect.(错)
2)ASCIIof'
A,is65.thenreadthefollowingprogramandtheresultofit.
Filltheblanks:
main()
{
chara;
a二'
A'
+11:
printf(“%c”,a);
}
result:
L
3)Togetacharacterwithgetchar(),youcaninputcorrespondingASCIInumberofthedesiredcharacterfromkeybord.(错)
floatf;
doublei;
10+'
a'
+i*fisdouble
1.常量
字符常量的定义形式:
#definePRICE30
字符常量定义后,在程序屮不能再改变其值,如PRICE++是错误的。
1)Incorrectstringconstantis:
(A)字符串常量
A.'
abc'
B.“1212"
C.“0"
D.“"
2)IfRateisasymbolconstant,wecanuseitasRate++.(错)
2.变量
其值可以改变的量称为变量。
一个变量应该有一个名字,在内存屮占据一定的存储单元,在该存储单元中存放变量的值。
变量与声明:
1)Asvariablename,tmpvarandTmpVararesame・(错)
2)Keywordscanbeusedasvariablenames・(错)
3)Thefirstcharacterofvariablenamemustbealetteroraunderscore(_).(对)
4)Whichofthefollowingiserror?
(A)
A・Keywordscanbeusedasvariablenames.
B・Wetendtouseshortnamesforlocalvariables,especiallyloopindices,andlongernamesforexternalvariables・
C.Uppercaseandlowercaselettersinvariablenamesaredistinct.
D.Thefirstcharacterofvariablenamemustbealetteroraunderscore(_).
变量赋初值
1)Thestatement:
intn1=n2=10;
iscorrect.(错)
2)Thedeclaration:
floatf二f+1.1;
3)Whichofthefollowingistheillegalvariablenames?
(D)
A.LadB.n_10C._567D.g#k
转义字符的应用
charc=,\010'
;
thenthecountofcharacterinvariablecis].
当变量成为计数器和累加器的时候如何初始化
1)Whenweusesumasanaccumulatingoracounting,weshouldfirstinitializedsumto0
作为计数器或累加器的变量在使用之前必须初始化为0,防止原來的垃圾数据影响程序的执行。
4.运算符和表达式
运算符:
自增自减运算符,逗号运算符
算术运算符,逗号运算符,
1)Theexpression"
(x=y=w=0,y=5+w,x=y)Hiswrong.o
这是一个逗号运算符的题目,逗号运算符具有最低优先级,
2)Theresultofexpression:
x=(i=4,j=16,k=32)is32.
3)Theoperandofoperator++/・・canbevariablesorconstants.自增自减运算符只能用于变量不能用于常量。
(错)
先计算,后取值。
(对)
4)The%operatorcannotbeappliedtoafloatordouble.
%是取余数的运算符,只能用在整型数中。
Assignmentoperatorhasthelowestprecedenceandaleft-to-rightassociativity.(错)
5.格式化输入与输出
1)Writetheresultoffollowingprogram5.2main()
floata=5.23;
printfC4%6.1f\a);
2)Supposecodesegment:
intkl,k2,k3,k4;
scanf("
%d%d”,&
k1,&
k2);
scanf('
'
%d,%cT,&
k3,&
k4);
ifwewantkl,k3getvalue10,
andk2,k4getvalue20,
thentheaccurateinputis」02()vcr>
10、20vcr>
・
6.注释及语句
1)Commentshavenoeffecttotheperformanceofprogram.(对)
2)Clanguagehasnoinput/outputstatementJustinput/outputfunctionsinstead.(对)
3)Writetheresultoffollowingprogram:
(JI)main()
intx=021;
printf(<
<
%x,,,x);
4)WritetheresultoffollowingDrogram:
(3」40000)
floata=3.14;
printf(u%f,,a);
5)InC,commentsmustbeginwith/*andendwith•
6)ACprogram,whateveritssize,consistsoffunction》andvariables.
7)Anexpressionbecomesastatementwhenitisfollowedbya:
_•
8)Valueoftheassignmentexpression:
c=25is_25
9)sum=sum+3canbewrittenassum+=3
第二章选择结构
1.关系运算
1)(x<
=y<
=z)isCIanguageexpressionforrelationshipxWyWz.(错)
2)Valueoftheexpression'
+l=='
b'
isfalse.(错)
逻辑运算符
!
&
&
||
=y)&
(xv二z)isClanguageexpressionforrelationshipxWyWz.(对)
2)Whenais1andbis0、thevalueofa||bistrue.(对)
3)Thedeclarationis:
intx=2,y=4,z=5;
whichofthefollowingexpressionequalsto0?
(D)
A.x&
yBx<
=yCx||y+z&
y-zD!
z
4)Inthefollowingoperators,whichonehasthelowestprecedenee?
(C)
A.*B.&
C.||D.=
关系表达式
1)Theresultofexpression:
3&
5||1%2is1.(对)
2)(ch>
='
A*)&
(chv二'
Z'
)cantellyouwheathervariablechisuppercase.(错)
3)Whichonecanexpressx$y3zcorrectly?
(A)
A(x>
=y)&
(y>
二z)B(x>
=y)and(y>
=z)Cx>
=y>
=zD(x>
=Y)&
(Y>
=z)
4)Thecorrectexpressonfor1WxW10andlOOWxW200is(1二10)&
(100v二xv=200).
5)Havingknowing:
intx=3,y=4,z=5;
amongfollowingexpressions,whosevaluearenot0(ABC)
x&
y'
B.x<
=yC.x||y+z&
y・zD.!
((x<
y)&
z||1)
条件运算符及条件表达式
1)Suppose