


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、C语言(双语)复习资料(2013)第1章C语言基础1. int, char, float, double are all basic data types in C language. (对)2. Provided that the length of int is 16 bits, then the value scope of unsigned int is:(B)A0255 B065535 C.-3276832767 D-2562553. The declaration is: int k=0,a=0,b=0; unsigned long w=5; double x=1.42,y=0;
2、then the incorrect expression is_A_Ay=x%3 B. w+= -2 C. x=w+5 D. k*=a+b4. In C, basic data types are int, char, float and _double_.5. Suppose declaration: char a=c; then statement: printf(“%d”,a); is wrong.(错)6. Suppose declaration: int a; float x,y;then the result data type of expression:x+a%3*(int)
3、(x+y)%2/4 is _float_.7. The data type of expression: 18/4*sqrt(4.0) is float. (错)8. Suppose declaration: char a; then expression: ch=5+9 is correct.(错)9. Incorrect string constant is: (A) A. abc B. “1212” C. “0” D. “ ”10. If Rate is a symbol constant,we can use it as Rate+. (错)11. As variable name,
4、tmpvar and TmpVar are same. (错)12. Keywords can be used as variable names. (错)13. The first character of variable name must be a letter or a underscore (_). (对)14. Which of the following is error?(A) AKeywords can be used as variable names. BWe tend to use short names for local variables, especially
5、 loop indices, and longer names for external variables. CUpper case and lower case letters in variable names are distinct. DThe first character of variable name must be a letter or a underscore (_).15. The statement: int n1=n2=10; is correct. (错)16. The declaration: float f=f+1.1; is correct. (错)17.
6、 Which of the following is the illegal variable names ?(D) ALad B. n_10 C. _567 D. g#k18. Suppose declaration: char c=101;then the count of character in variable c is _A_.(对)19. Suppose declaration: char c=061;then the count of character in variable c is _1_.(对)20. Suppose declaration: char c=n;then
7、 the count of character in variable c is _new-line_.(对)说明:转义字符以 开头, nnn 必须是8进制数。102可以视为一个字符。21.The expression (x=y=w=0,y=5+w, x=y) is wrong.。 (错)这是一个逗号运算符的题目,逗号运算符具有最低优先级,先计算,后取值。22. The result of expression: x=(i=4,j=16,k=32) is 32. (对)23. The operand of operator +/- can be variables or constants.
8、(错)说明:自增自减运算符只能用于变量不能用于常量。例 i+ , -k (对) 3+ -6 (错)24. The % operator cannot be applied to a float or double. (对)(%是取余数的运算符,只能用在整型数中)25. Comments have no effect to the performance of program. (对)26. C language has no input/output statement, just input/output functions instead. (对)27. In C, comments mu
9、st begin with _/*_ and end with _*/_. (对)28. A C program, whatever its size, consists of _ functions_ and variables. (对)29. An expression becomes a statementwhen it is followed by a _;_. (对)30. Value of the assignment expression: c=25 is _25_ (对)31. sum=sum+3 can be written as _ sum+=3_ (对)第2章 选择结构1
10、. (x=y=z) is C language expression for relationship xyz. (错)2. Value of the expression a+1=b is false. (错)3. (x=y) & (x=z) is C language expressionfor relationship xyz. (对)4. When a is 1 and b is 0, the value of a|b is true. (对)5. The declaration is: int x=2,y=4,z=5;which of the following expression
11、 equals to 0 ?(D)Ax & y B x7. The result of expression: 3&5|1%2 is 1. (对)8. (ch=A)&(ch=y)&(y=z) B. (x=y)and(y=z) C. x=y=z D. (x=Y)&(Y=z)10. The correct expresson for 1x10 and 100 x200 is _ (1=x=10) & (100=xx?w:yz?y:z is 4. (对)12. After running following block of program, value of variable m is ( D )
12、int w=1,x=2,y=3,z=4,m;m=(wx)?w:x; m=(my)?m:y; m=(mz)?m:z;A4 B 3 C 2 D 113. Suppose the following code segment: int w=1,x=2,y=3,z=4,m; m=(wx)?w:x ; / m=1 m=(my)?m:y; / m=1 m=(mz)?m:z; / m=1 finally the value of m is _1_. (对) 14. The statement: if (x=y)&(x!=0) x+y; is correct. (错)15. The statement if
13、(xy) x=y , else x=-y, is not correct. (对)16. The statement if (n) means if n is not 0. (对)17. The result of the following program is( C ) main() int i=1,j=1,k=2; if(j+|k+)&i+)/ 短路运算致使k 未运算k=2。 printf(%d,%d,%dn,i,j,k);A1,1,2 B 2,2,1 C 2,2,2 D 2,2,318. If we use the following four expressions as contr
14、ol expression for if statement, which one has different meanings to others? (D)A. k%2 B. k%2 = 1 C. (k%2)!=0 D. k%2 = 0 /前3项都是判别if(1)执行,19. C language request in embeded if statement ,the use of else must be 与离它最近的上方的一个if匹配。19. The switch statement is a multi-way decision. (对)20. In the statement sw
15、itch(expression), expression can be any type. (错)第3章 循环结构1. The statement: for (a=0,b=1,i=0; i=200; i+) is correct . (对)2. The result of the following block of program is:(D) for(x=3;x6; x+) if(x%2 !=0) printf(“*%d”,x); else printf(“#%dn”,x); A*3 #4*5 B #3*4#5 C #3*4#5 D *3#4*53. Write the result of
16、 following program:(_23_)main() int count; count=2; for(; count=20;count+=3); /* count 增量:5 8 11 14 17 20*/ printf(%d,count); /*退出循环后,20+3*/4. Suppose code segment: int k=10;while (k=0) k=k-1; then the loop will execute 10 times. (错)说明: 循环不执行,因为while( ) 语句执行时必须while(1).5. Write the result of followi
17、ng program:(_21_)main() int num=0; while(num=20) num+; printf(%d,num);说明: 当num=21 时 退出循环,所以结果为21.6. In do-while, the loop is executed at lest once. (对)7. The result of the following program is: (A) int a=1,b=1; do a+; b-; while(b0); printf(“a=%d,b=%dn”,a,b);Aa=2,b=0 B a=1,b=1 C a=3,b=-1 D a=2,b=1说明:
18、 do-while( ) 必须执行一次,所以 a+为 2 ,b为0, while(b0) 条件不满足,退出循环。第4章 函数1. Which of the following function definitions is correct?(A) Adouble fun(int x, int y) B double fun(int x; int y) Cdouble fun(int x, y) D double fun(int x, y;)2. Which of the following statements is correct?(A) A. C programs generally co
19、nsist of many small functions . B. Functions may be defined within other functions. C. In C program, you have to put main() function before all other functions. D. In C, a function has to be defined before any other code can call it.3.When we use function,we have two methods to pass value from the c
20、alling function to the called function:pass by value and pass by reference. (对)4. In C language, some functions needs return no value , which keywords is used to denote this?(A) A. void B. int C. float D. double5. Which one is the result of the following program? (D)void fun(char c,int d)c=c+1; /c=a
21、+1 (b)d=d+1; /d=A+1 (B)printf(%c,%c,c,d);main() char a=A, b=a; fun(b,a); printf(%c,%cn,a,b); / a=A, b=a /单向传递a,b 值未变 A. B,b,A,a B. B,a,B,a C. A,a,B,b D. b,B,A,a第5章 数组1. Array initialization: int grade5=1,2,3,4; So the value of grade5 is 5 (错)2. Which of the following string assignment statements is
22、correct?(B) Astring s=abcde; B. static char s =abcde; Cstr s=abcde; D char s=abcde;3. Choose the result of the following program: (B) #include void main(void) char c=a,b,c,d,0,*p_c; p_c=c; c2=0; printf(%s,c); Aa B. ab C. abc D. abcd说明: c0 c1 c2 c3 c4 a b c d 0 c0 c1 c2 c3 c4 a b 0 d 说明:字符串输出 %s 时,遇到
23、0时,就视为字符串结束。4. Write the result of following program:(_ hELLO!_)main() char s80,*sp=HELLO!; sp=strcpy(s,sp); s0=h; puts(sp);5. The result of strcmp(STUDY,study) is 0. (错)说明: 大写字母与小写字母ASCII值不一样。第6章 指针1. A pointer contains the address of a variable. (对)2. Find the output of the following program (D)po
24、int(char *p)p+=3; /指针移动到3(指向第3单元)main() char b4=a,b,c,d,*p=b; point(p);printf(%cn,*p); Aa B b C c D d3. Provided that the declaration is: int *p ,m=5,n; which of the following statements is correct? (D) A. p=&n; scanf(“%d”, &p); B. p=&n; scanf(“%d”,*p); C. scanf(“%d”,&n);*p=n; D. p=&n; *p=m;4. Provi
25、ded that the sizeof(int) equals 4,then the result of the following program is: (A) # include “stdio.h” struct date int year,month,day; today; main() printf( “%dn”,sizeof(today); A12 B. 8 C. 10 D. 9 说明:在C+ 系统中,int 的长度为4字节。编程题编程题:Suppose string2=“computers”,write a grogram to copy the contents of stri
26、ng2 to string1.参考程序:#include main()static char string2=“computers”;static char string110;int i=0;while(string2i!=0) string1i=string2i; i+;string1i=0;return;Write a program which calculate sum of diagonal of a 3*3 matrix.(矩阵对角线)参考程序: #include main()int a33,sum=0;int i,j;printf(“Enter data:n”);for(i=0
27、;i3;i+) for(j=0;j3;j+) scanf(“%d”,&aij); for(i=0;i3;i+) sum=sum+aii; printf(“sum=%5dn”,sum); *3. Input three integer numbers a,b and c with comma(逗号), then output them in ascending order(升序). 参考程序:#include main()int t,a,b,c;printf( please input 3 numbers with comma: );scanf(%d,%d,%d,&a,&b,&c);if (ab
28、) t=a;a=b;b=t;if (ac) t=a;a=c;c=t;if (bc) t=b;b=c;c=t;printf(n The result of sort is as following: );printf( %d %d %d n,a,b,c);return 0; 4.Input a character, and tell wheather the character is a letter, digit or a special character.参考程序:#include main()char c;c=getchar();if(c=a&c=A&c=0&c=9) printf(%c
29、 is a digit n,c); else printf(%c is a spicial charactern,c); * 5. Programming to get the result of the expression as :1+2+3+100.参考程序: #include int main( ) int k; int sum; k=1; sum=0; for (k=1;k=100;k+) sum=sum+k; printf(%d n, sum); return 0; *6. Write a program that prompts the user for a number and then prints message telling whether the digit is odd or even.(奇偶数)参考程序:#include main()int a;printf(Input a digit number: );scanf(%d,&a);if (a%2=0)prin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医务部医疗事故处理总结与反思计划
- 建筑节能设计模型考核试卷
- 创新实践在学校艺术教育中的应用计划
- 贴广告合同范本
- 手工纸制作中的常见问题及解决方法考核试卷
- 食堂租赁合同范本
- 科技创新在环保生活中的应用
- 班主任角色定位与职责计划
- 深度解读现代商业著作探索市场先机
- 2024年12月浙江省第七地质大队编外人员公开招聘6人笔试历年典型考题(历年真题考点)解题思路附带答案详解-1
- GB/T 5796.3-1986梯形螺纹基本尺寸
- GB/T 4851-2014胶粘带持粘性的试验方法
- GB/T 3860-2009文献主题标引规则
- GB/T 34376-2017数控板料折弯机技术条件
- GB/T 13277.3-2015压缩空气第3部分:湿度测量方法
- 人教版小学精通英语单元五下Unit1整合教案
- (课件)港口安全知识培训讲解
- 2022年企业安全生产知识培训讲座PPT课件(带内容)
- 产品设计思维课件
- 电子直线加速器的工作原理专题培训课件
- 2023年孝感市孝南区全要素自然资源有限公司招聘笔试题库及答案解析
评论
0/150
提交评论