版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C涪言(双语)复习资料(2013)
第1章C语言基础
1.int,char,float,doubleareallbasicdatatypesinClanguage.(对)
2.Providedthatthelengthofintis16bits,thenthevaluescopeofunsignedint
is:(B)
A.0~255B.0^65535C.-32768^32767D.-256~255
3.Thedeclarationis:
intk=0,a=0,b=0;
unsignedlongw=5;
doublex=l.42,y=0;
thentheincorrectexpressionisA__
A.y=x%3B.w+=-2C.x=w+5D.k*=a+b
4.InC,basicdatatypesareint,char,floatanddouble.
5.Supposedeclaration:chara='c';thenstatement:printf(u%d'\a);iswrong.(错)
6.Supposedeclaration:
inta;
floatx,y;
(hentheresultdatatypeofexpression:
x+a%3*(int)(x+y)%2/4isfloat.
7.Thedatatypeofexpression:18/4*sqrt(4.0)isfloat.(错)
8.Supposedeclaration:chara;thenexpression:ch='5+9'iscorrect.(错)
9.Incorrectstringconstantis:(A)
A.'abc'B.“1212”C.“0"D.“”
10.IfRateisasymbolconstant,wecanuseitasRatc++.(错)
11.Asvariablename,tmpvarandTmpVararesame.(to)
12.Keywordscanbeusedasvariablenames.(错)
13.Thefirstcharacterofvariablenamemustbealetteroraunderscore(_).(对)
14.Whichofthefollowingiserror?(A)
A.Keywordscanbeusedasvariablenames.
B.Wetendtouseshortnamesforlocalvariables,especiallyloopindices,andlongernames
forexternalvariables.
C.Uppercaseandlowercaselettersinvariablenamesaredistinct.
D.Thefirstcharacterofvariablenamemustbealetteroraunderscore(_).
15.Thestatement:intnI=n2=10;iscorrect.(错)
16.Thedeclaration:floatf=f+1.1;iscorrect.(错)
17.Whichofthefollowingistheillegalvariablenames?(D)
A.LadB.n_10C._567D.g#k
18.Supposedeclaration:charc=,\10r;thenthecountofcharacterinvariablecisA.(对)
19.Supposedeclaration:charc='\06r;thenthecountofcharacterinvariablecis」.(对)
20.Supposedeclaration:charc=,\n\thcnthecountofcharacterinvariablecis」iew-line.
(对)
说明:转义字符以'开头,\nnn必须是8进制数。'\102'可以视为一个字符。
2l.Theexpression"(x=y=w=0,y=5+w,x=y)"iswrong.。(错)
这是一个逗号运算符的题n,逗号运算符具有最低优先级,先计算,后取值。
22.Theresultofexpression:x=(i=4,j=16,k=32)is32.(对)
23.Theoperandofoperator++/-canbevariablesorconstants.(错)
说明:自增自减运算符只能用于变量不能用于常量。例i++,一k(对)3++-6(错)
24.The%operatorcannotbeappliedtoafloatordouble.(对)
(%是取余数的运算符,只能用在整型数中)
25.Commentshavenoeffecttotheperformanceofprogram.(对)
26.Clanguagehasnoinput/outputstatement,justinput/outputfunctionsinstead.(对)
27.InC,commentsmustbeginwith/*andendwith*/.(对)
28.ACprogram,whateveritssize,consistsoffunctionsandvariables.(对)
29.Anexpressionbecomesastatementwhenitisfollowedbya:.(对)
30.Valueoftheassignmentexpression:c=25is25(对)
31.sum=sum+3canbewrittenassum+=3(对)
第2章选择结构
1.(x<=y<=z)isClanguageexpressionforrelationshipxWyWz.(错)
2.Valueoftheexpression=,b,isfalse.(错)
3.(x<=y)&&(x<=z)isClanguageexpressionforrelationshipx<yWz.(对)
4.Whenais1andbis0,thevalueofa||bistrue.(对)
5.Thedeclarationis:
intx=2,y=4,z=5;
whichofthefollowingexpressionequalsto0?(D)
A.x&&yBx<=yCx||y+z&&y-zD!z
6.Inthefollowingoperators,whichonehasthelowestprecedence?(C)
A.*B.&&C.||D.=>
7.Theresultofexpression:3&&5||1%2is1.(对)
8.(ch>='A')&(ch<='Z,)can(ellyouwheathervariablechisuppercase.(错)(必须用“&&")
9.Whichonecanexpressx>y^zcorrectly?(A)
A.(x>=y)&&(y>=z)B.(x>=y)and(y>=z)C.x>=y>=zD.(x>=Y)&&(Y>=z)
10.Thecorrectexpressonfor1WxW10and100WxW200is(1v=xv=10)&&(10Qv=xv=200).
11.Supposedeclaration:w=1,x=2,y=3,z=4;thcnthevalueofvv>x?w:y>z?y:zis4.(对)
12.Afterrunningfollowingblockofprogram,valueofvariablemis(D)
intw=1,x=2,y=3,z=4,m;
m=(w<x)?w:x;in=(m<y)?rn:y;m=(m<z)?ni:z;
A.4B3C2D1
13.Supposethefollowingcodesegment:
intw=1,x=2,y=3,z=4,m;
m=(w<x)?w:x;/!m=1
m=(m<y)?m:y;Hm=1
m=(m<z)?m:z;//m=1
finally(hevalueofmis1.(对)
14.Thestatement:if(x=y)&&(x!=0)x+y;iscorrect.(错)
15.Thestatementif(x<y)x=y,elsex="y,isnotcorrect.(对)
16.Thestatementif(n)meansifnisnot0.(对)
17.Theresultofthefollowingprogramis(C)
main()
{inti=l,j=l,k=2;
if((j++||k++)&&i++)//短路运算致使k未运算k=2。
printf("%d,%d,%d\n",i,j,k);
)
A.1,1,2B2,2,1C2,2,2D2,2,3
18.Ifwcusethefollowingfourexpressionsascontrolexpressionforifstatement,whichonehas
differentmeaningstoothers?(D)
A.k%2B.k%2==1C.(k%2)!=0D.k%2==()〃前3项都是判别if⑴执行,
19.Clanguagerequestineinbededifstatement,theuseofelsemustbe与离它最近的上方的一
个if匹配。
19.Theswitchstatementisamulti-waydecision.(对)
20.Inthestatementswitch(cxprcssion),expressioncanbeanytype.(1普)
第3章循环结构
I.Thestatement:fbr(a=0,b=l,i=0;i<=200;i++)iscorrect.(对)
2.Theresultofthefollowingblockofprogramis:(D)
fbr(x=3;x<6;x++)
{
if(x%2!=0)
printff**%d,,,x);
else
printf^44##%d\n,,,x);
I
A.**3##4**5B##3**4##5C##3**4##5D**3##4**5
3.Writetheresultoffollowingprogram423)
main()
{
intcount;
count=2;
for(;count<=20;count+=3);/*count增量:5811141720*/
printf("%d",count);/*退出循环后,20+3*/
}
4.Supposecodesegment:
intk=10;
while(k=0)
k=k-l;
thentheloopwillexecute10times.(错)
说明:循环不执行,因为whi侬)语句执行时必须while(l).
5.Write(heresultoffollowingprogram:(_21)
main()
(
intnum=0;
while(nuin<=20)
num++;
printf("%d",num);}
说明:当num=21时退出循环,所以结果为21.
6.Indo-while,theloopisexecutedatlestonce.(对)
7.Theresultofthefollowingprogramis:(A)
inta=1,b=I;
do
{
a++;b—;
}while(b<0);
printf(tia=%d,b=%d\nv,a,b);
A.a=2,b=0Ba=1,b=1Ca=3,b=-lDa=2,b=l
说明:do-while()必须执行一次,所以a++为2,b一为0,while(b<0)条件不满足,退
出循环。
第4章函数
I.Whichofthefollowingfunctiondefinitionsiscorrect?(A)
A.doublefun(intx,inty)Bdoublefun(intx;inty)
C.doublefun(intx,y)Ddoublefun(intx,y;)
2.Whichofthefollowingsiatementsiscorrect?(A)
A.Cprogramsgenerallyconsistofmanysmallfunctions.
B.Functionsmaybedefinedwithinotherfunctions.
C.InCprogram,youhavetoputmain()functionbeforeallotherfunctions.
D.InC,afunctionhastobedefinedbeforeanyothercodecancallit.
3.Whenweusefunction,wehavetwomethodstopassvaluefromthecallingfunctiontothecalled
functionpassbyvalueandpassbyreference.(对)
4.InClanguage,somefunctionsneedsreturnnovalue,whichkeywordsisusedtodenote
this?(A)
A.voidB.intC.floatD.double
5.Whichoneistheresultofthefollowingprogram?(D)
voidfun(charc,intd)
(
c=c+1;〃c='a'+l(b)
d=d+l;〃d='A'+l(B)
printf("%c,%c,”,c,d);
main()
chara='A\b-a';
fun(b,a);
printf("%c,%c\n",a,b);〃a='A',b='a'〃单向传递a,b值未变
I
A.B,b,A,aB.B,a,B,aC.A,a,B,bD.b,B,A,a
第5章数组
1.Arrayinitialization:intgradcl5]={1,2,3,4};Sothevalueofgrade15Jis5(错)
2.Whichofthefollowingsiringassignmentstatementsiscorrect?(B)
A.strings="abcde";B.staticchars[]={"abcde"|;
C.strs="abcde";Dchars="abcde^^;
3.Choosetheresultofthefollowingprogram:(B)
#include<stdio.h>
voidmain(void)
{
charc[]={,a,,V;c','d';\O,},*P,c;
P_c=c;
c[2]=A0';
printf("%s",c);
)
A.aB.abC.abcD.abed
说明:
clO]cLIJcl2Jcl3]c14j
abcd\0
clOJ41]cl2JcL3]cl4]
ab\0d
说明:字符串输出%s时,遇到,\0'时,就视为字符串结束。
4.WritetheresultoffollowingDroeram:(hELLO!)
main()
(
chars[80],*sp="HELLO!”;
sp=strcpy(s,sp);
s[0]='h';
puts(sp);
)
5.TheresultofstrcmpC'STUDY'V^tudy")is0.(错)
说明:大写字母与小写字母ASCH值不一样。
第6章指针
1.Apointercontainstheaddressofavariable.(对)
2.Findtheoutputofthefollowingprogram(D)
point(char*p){p+=3;}〃指针移动到3(指向第3单元)
main()
{charbr4]={,a';b,,'c','d,},*p=b;
point(p);printf("%c\n",*p);
)
A.aBbCcDd
3.Providedthat(hedeclarationis:
int*p,m=5,n;
whichofthefollowingstatementsiscorrect?(D)
A.p=&n;scanf("%d",&p);B.p=&n;scanf('、%d",*p);
C.scanf(lk%d'\&n);*p=n;D.p=&n;*p=m;
4.Providedthatthesizeof(int)equals4,thentheresultofthefollowingprogramis:(A)
#include“stdio.h"
structdate
{
intyear,month,day;
}today;
main()
(
prints"%d\n”,sizeofOoday));
)
A.12B.8C.10D.9
说明:在C++系统中,int的长度为4字节。
编程题
编程题:
I.Supposestring2[]={"computers"),writeagrogramtocopythecontentsofstring?tostring!.
参考程序:
#includc<stdio.h>
main()
|
staticcharstring2[]={"compulers"};
staticcharstring1[10];
inti=0;
while(string2[i]!=,\0,)
{stringl[i]=string2li];
i++;
stringl[i]='\O';
return;
I
2.Writeaprogramwhichcalculatesumofdiagonalofa3*3matrix.(矩阵对角线)
参考程序:
#include<stdio.h>main()
{inta[3][3],sum=O;
inti,j;
printf^uEnterdata:\n");
for(i=0;i<3;i++)
for(j=0;j<3y++)
scanR"%d'',&a[i]U]);
for(i=0;i<3;i++)
suni=sum+a[i][i];
prinm“sum=%5d\n”,sum);}
*3.Inputthreeintegernumbersa,bandcwithcomma(逗号),thenoutputtheminascending
order(升序).
参考程序:
#include<stdio.h>
niain()
{intt,a,b,c;
printf("pleaseinput3numberswithcomma:");
scanf("%d,%d,%d",&a,&b,&c);
if(a>b)
{t=a;a=b;b=t;)
if(a>c)
{t=a;a=c;c=t;}
if(b>c)
{t=b;b=c;c=t;}
printf("\nTheresultofsortisasfollowing:");
prinlfC%d%d%d\nH,a,b,c);
return0;}
4.Inputacharacter,andtellwheatherthecharacterisaletter,digitoraspecialcharacter.
参考程序:
#include<stdio.h>
main()
{chare;
c=getchar();
if(c>=,a'&&c<='z,||c>='A'&&c<='Z,)
printf("%cisaletter\n",c);
elseif(c>='0'&&c<=9,)
printf("%cisadigit\n",c);
else
printf("%cisaspicialcharacter\n'\c);}
*5.Programmingtogettheresultoftheexpressionas:1+2+3+.......+100.
参考程序:
#include<stdio.h>
intmain()
{intk;
intsum;
k=l;
sum=0;
for(k=l;k<=100;k++)
sum=suni+k;
printf("%d\n'\sum);
return0;}
*6.Writeaprogramthatpromptstheuserforanumberandthenprintsmessagetellingwhether
thedi
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年大数据评估软件开发协议
- 2026年零售检测审计评估合同
- 2025年四川省西昌市高二生物下册期末考试检测卷含答案【典型题】
- 2026年吉林省敦化市高二生物下册期末考试模拟卷(各地真题)附答案
- 2026年山东省禹城市高二生物下册期末考试测试卷【突破训练】附答案
- 2025年浙江省临海市高二生物下册期末考试试卷及答案【易错题】
- 2025年河南省孟州市高二生物下册期末考试试卷及完整答案(必刷)
- 2026年吉林省德惠市高二生物下册期末考试检测卷含答案【突破训练】
- 2025年山东省昌邑市高二生物下册期末考试检测卷【重点】附答案
- 2025年吉林省磐石市高二生物下册期末考试检测卷(突破训练)附答案
- 充电桩方案汇报
- 2026年贵州中考数学考试卷及答案
- 2025年国家开放大学(电大)《民法学》期末考试复习题库及答案解析
- 沪语童谣课件
- DB34T 2421-2015 地理标志产品 李兴桔梗
- 新司机岗前安全培训内容课件
- DB61T 1203-2018 便携式氧气吸入器通 用要求
- 政治文本翻译课件
- 互联网保险业务营销宣传管理细则考试题及答案
- 一年级下册数学乐考材料-遨游太空探索奥秘【课件】
- 2025年护肤品行业白皮书
评论
0/150
提交评论