资源描述:
《双语c期末复习资料(2012级-注释)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、复习概要第一章C语言基础1)int,char,float,doubleareallbasicdatatypesinClanguage.(对)2)Providedthatthelengthofintis16bits,thenthevaluescopeofunsignedintis:(B)A.0~255B.0~65535C.-32768~32767D.-256~2553)Thedeclarationis:intk=0,a=0,b=0;
unsignedlongw=5;
doublex=1.42,y=0
2、;
thentheincorrectexpressionis_A__A.y=x%3B.w+=-2C.x=w+5D.k*=a+b4)InC,basicdatatypesareint,char,floatand_double_____.混合数据类型的运算1)Supposedeclaration:(假设陈述)chara=’c’;thenstatement:printf(“%d”,a);iswrong.(错)2)Supposedeclaration:inta;floatx,y;thentheresultd
3、atatypeofexpression:x+a%3*(int)(x+y)%2/4is_float_____.3)Thedatatypeofexpression:18/4*sqrt(4.0)isfloat.(错)字符的ASCII值及其合理应用Supposedeclaration:chara;thenexpression:ch=’5+9’iscorrect.(错)
ASCIIof‘A’is65.thenreadthefollowingprogramtheresultofit.
Filltheblank
4、s:
main()
{
chara;
a=’A’+__4____;
printf(“%c”,a);
}
result:E常量字符常量的定义形式:#definePRICE30字符常量定义后,在程序中不能再改变其值,如PRICE++是错误的。Incorrect(错误的)stringconstantis:(A)字符串常量A.‘abc’B.“1212”C.“0”D.“”2)IfRateisasymbolconstant,wecanuseitasRate++.(错)变量其值可以改变的量称为变量。一个变量应该
5、有一个名字,在内存中占据一定的存储单元,在该存储单元中存放变量的值。变量与声明:1)Asvariablename,tmpvarandTmpVararesame.(错)2)Keywordscanbeusedasvariablenames.(错)3)Thefirst(characterofvariable)(字符变量)namemustbealetteroraunderscore(强调)(_).(对)4)Whichofthefollowingiserror?(A)A.Keywordscanbeuseda
6、svariablenames.B.Wetendtouseshortnamesforlocalvariables,especiallyloopindices,andlongernamesforexternalvariables.C.Uppercaseandlowercaselettersinvariablenamesaredistinct.D.Thefirstcharacterofvariablenamemustbealetteroraunderscore(_).变量赋初值1)Thestatemen
7、t:intn1=n2=10;iscorrect.(错)2)Thedeclaration:floatf=f+1.1;iscorrect.(错)3)Whichofthefollowingistheillegalvariablenames?(D)A.LadB.n_10C._567D.g#k转义字符的应用1)Supposedeclaration:charc=’101’;thenthecountofcharacterinvariablecis___A__.2)Supposedeclaration:char
8、c=’ 61’;thenthecountofcharacterinvariablecis___1__.3)Supposedeclaration:charc=’’;thenthecountofcharacterinvariablecis___new-line_.说明:转义字符以开头,nn必须是8进制数。‘102’可以视为一个字符。当变量成为计数器和累加器的时候如何初始化1)Whenweusesumasanaccumulatingoracounting,weshouldf