昆明理工大学C语言复习资料.doc_第1页
昆明理工大学C语言复习资料.doc_第2页
昆明理工大学C语言复习资料.doc_第3页
昆明理工大学C语言复习资料.doc_第4页
昆明理工大学C语言复习资料.doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

复习资料第一章 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;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) Given declaration: char c=035; the size of c is _1_bytes.混合数据类型的运算1)Suppose declaration: char a=c; then statement: printf(“%d”,a); is wrong.(错)2)Suppose declaration: int a; float x,y;then the result data type of expression:x+a%3*(int)(x+y)%2/4 is _float_.3)The data type of expression: 18/4*sqrt(4.0) is float. (错)字符的ASCII值及其合理应用1)Suppose declaration: char a; then expression: ch=5+9 is correct.(错)2) ASCII of A is 65.then read the following programand the result of it.Fill the blanks: main() char a; a=A+_11_; printf(“%c”,a); result: L3) To get a character with getchar(), you can input corresponding ASCII number of the desired character from keybord.(错)1) Suppose declaration: int a; float f; double i; then the result data type of expression: 10+a+i*f is _double_.1. 常量字符常量的定义形式:#define PRICE 30字符常量定义后,在程序中不能再改变其值,如PRICE+是错误的。1) Incorrect string constant is: (A) 字符串常量A. abc B. “1212” C. “0” D. “ ”2)If Rate is a symbol constant,we can use it as Rate+. (错)2. 变量其值可以改变的量称为变量。一个变量应该有一个名字,在内存中占据一定的存储单元,在该存储单元中存放变量的值。变量与声明: 1) As variable name, tmpvar and TmpVar are same. (错)2) Keywords can be used as variable names. (错)3)The first character of variable name must be a letter or a underscore (_). (对)4)Which of the following is error?(A) AKeywords can be used as variable names. BWe tend to use short names for local variables, especially 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 (_).变量赋初值1)The statement: int n1=n2=10; is correct. (错)2)The declaration: float f=f+1.1; is correct. (错)3)Which of the following is the illegal variable names ?(D) ALad B. n_10 C. _567 D. g#k转义字符的应用1)Suppose declaration: char c=010;then the count of character in variable c is _1_.当变量成为计数器和累加器的时候如何初始化1)When we use sum as an accumulating or a counting ,we should first initialized sum to _0_ 作为计数器或累加器的变量在使用之前必须初始化为0,防止原来的垃圾数据影响程序的执行。4. 运算符和表达式运算符:自增自减运算符,逗号运算符算术运算符,逗号运算符,1)The expression (x=y=w=0,y=5+w, x=y) is wrong.。 (错)这是一个逗号运算符的题目,逗号运算符具有最低优先级,先计算,后取值。2)The result of expression: x=(i=4,j=16,k=32) is 32. (对)3)The operand of operator +/- can be variables or constants. (错)自增自减运算符只能用于变量不能用于常量。4)The % operator cannot be applied to a float or double. (对)%是取余数的运算符,只能用在整型数中。Assignment operator has the lowest precedence and a left-to-right associativity. (错)5. 格式化输入与输出1)Write the result of following program 5.2main() float a=5.23; printf(“%6.1f”,a);2)Suppose code segment: int k1,k2,k3,k4; scanf(“%d%d”,&k1,&k2); scanf(“%d,%d”,&k3,&k4);if we want k1,k3 get value 10, and k2,k4 get value 20, then the accurate input is_10 2010,20_.6. 注释及语句1)Comments have no effect to the performance of program. (对)2)C language has no input/output statement, just input/output functions instead. (对)3)Write the result of following program:(_11_)main() int x=021; printf(“%x”,x);4)Write the result of following program:(_ 3.140000_)main() float a=3.14; printf(“%f”,a);5)In C, comments must begin with _/*_ and end with _*/_.6) A C program, whatever its size, consists of _ functions_ and variables.7) An expression becomes a statementwhen it is followed by a _;_.8) Value of the assignment expression:c=25 is _25_9) sum=sum+3 can be written as _ sum+=3_第二章 选择结构1. 关系运算1)(x=y=z) is C language expression for relationship xyz. (错)2)Value of the expression a+1=b is false. (错)逻辑运算符! & | |1)(x=y) & (x=z) is C language expressionfor relationship xyz. (对)2)When a is 1 and b is 0, the value of a|b is true. (对)3)The declaration is: int x=2,y=4,z=5;which of the following expression equals to 0 ?(D)Ax & y B x=A)&(ch=y)&(y=z) B (x=y)and(y=z) C x=y=z D (x=Y)&(Y=z)4) The correct expresson for 1x10 and 100x200 is _ (1=x=10) & (100=x=200)_.5) Having knowing: int x=3, y=4, z=5; among following expressions, whose value are not 0( A B C)A. x&y B. x=y C. x|y+z&y-z D. !(xx?w:yz?y:z is 4. (对)2)After running following block of program, value of variable m is ( D )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 13) Suppose the following code segment: int w=1,x=2,y=3,z=4,m; m=(wx)?w:x; m=(my)?m:y; m=(mz)?m:z;finally the value of m is _1_.2. if语句1)The statement: if (x=y)&(x!=0) x+y; is correct. (错)2)The statement if (xy) x=y , else x=-y, is not correct. (对)3)The statement if (n) means if n is not 0. (对)4)The result of the following program is( C ) main() int i=1,j=1,k=2; if(j+|k+)&i+) printf(%d,%d,%dn,i,j,k);A1,1,2 B 2,2,1 C 2,2,2 D 2,2,35) Read the following program and the result of it. Fill the blanks.main() int _a=1_,b=2,c=3; if (c=a)printf(“%dn”,c); else printf(“%dn”,b);result: 15) If we use the following four expressions as control 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 = 06) main() int a=100,x=10,y=20,ok1=5,ok2=1; if(xy) if(y!=10) if(!ok1) a=1; else if(ok2) a=10;finally the value of a is _10_.7) The piece of program will output whether a year is a leap year or not. Leap year:could divided by 4 but could not divided by 100;(2) could divided by 400.main()int year,leap; printf(“input year:”); scanf(“%d”,&year); if(year%400=0) _ leap=1_; else if(year%4=0)&(year%100!=0)leap=1; else leap=0;if(leap!=_1_) printf(“%d is a leap yearn”,year);else printf(“%d is not a leap yearn”,year);8) Having known :int a=1,b=2,c=3,x;,after running following block of program,,the satements which enable value of x to be 3 are_ A D _。A. if(ca) x=1; else if(b3) x=3; else if(a2) x=2; else x=1;C. if(a3) x=1; if(a2) x=2; if(a1) x=3; D. if(ab) x=b; if(bC) x=c; if(ca) x=a;9) C language request in embeded if statement ,the use of else must be 与离它最近的上方的一个if匹配。3. switch语句1)The switch statement is a multi-way decision. (对)2)In the statement switch(expression), expression can be any type. (错)第三章 循环结构1. for循环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 following program:(_23_)main() int count; count=2; for(; count=0)iArri=100;i-; 3)Write the result of following program:(_21_)main() int num=0; while(num=20) num+; printf(%d,num);3. dowhile循环1)In do-while, the loop is executed at lest once. (对)2)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第四章 函数1. 函数的定义1)Which of the following function definitions is correct?(A) Adouble fun(int x, int y) B . fun(int x=0; int y) Cdouble (int x, y) D. int fun(int x=0, y;)2) Which of the following statements is correct?(A) A. C programs generally consist 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.2. 函数参数和函数的值1)When we use function,we have two methods to pass value from the calling function to the called function:pass by value and pass by reference. (对)2) In C language, some functions needs return no value , which keywords is used to denote this?(A) A. void B. int C. float D. double3. 函数调用1) Which one is the result of the following program?(D)void fun(char c,int d) c=c+1; d=d+1; printf(%c,%c,c,d);main( ) char a=A, b=a; fun(b,a); printf(%c,%cn,a,b); A. B,b,A,a B. B,a,B,a C. A,a,B,b D. b,B,A,a第五章 数组1. 一维数组1)Array initialization: int grade5=1,2,3,4; So the value of grade5 is 5 (错)2. 二维数组1)Write the result of following program: 30main() int a33=1,2,9,3,4,8,5,6,7,i,s=0; for(i=0;i3;i+) s+=aii+ai3-i-1; printf(%dn,s);3. 字符数组1)Suppose the declaration: char x=abcdefg; char y=a,b,c,d,e,f,g;then array x and array y have same storage size. (错)2)Which of the following string assignment statements is 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输入输出1)Write the result of following program:(_ hELLO!_)main() char s80,*sp=HELLO!; sp=strcpy(s,sp); s0=h; puts(sp);字符串处理函数1)The result of strcmp(STUDY,study) is 0. (错)第六章 指针1. 指针与变量1)A pointer contains the address of a variable. (对)2)Find the output of the following program (D)point(char *p)p+=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;第七章 结构体1)Provided 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 The output of the program is:The distance between p1 to origin is:_ 5.00_多选题:1. Which of the following is the legal variable names ?A.Lad B.n&10 C._567 D. g#k (1) A,C2.Which of the following is legal character constant ?A.h B. x7 C.101 D.483 (1) A,B,C3.Incorrect string constant is:A.abc B.“1212” C. “0” D.1234 (2) A,D4.Having known :int a=1,b=2,c=3,x;,after running following block of program,,the satements which enable value of x to be 3 are_ _。A.if(ca) x=1; else if(b3) x=3; else if(a2) x=2; else x=1;C.if(a3) x=1; if(a2) x=2; if(a1) x=3;D.if(ab) x=b; if(bC) x=c; if(ca) x=a; (2) A D5.Having knowing: int x=3, y=4, z=5; among following expressions, whose value are not 0.A.x&y B.x=y C.x|y+z&y-z D. !(xy)&!z|1) (3) A B C6. Which of the following is legal for statement?A.for (; ;) B.for(3;4;1) C.for(i=1;i10;) D.for(k=1;k=5;k+) (3) A,C,D7.The same result of the following statements are:A.for(i=1;i=100;i+) s=s+i;B.for(i=1;i=100;) s=s+i;i+;C.for(i=1;i=100;) s=s+i;i+;D.i=1;while(i=100)s=s+i;i=i+1; (5) A,B,D8.The correct two-dimesional arrays initilization areA. int a23=1,2,3,3,4,5;B. int a 3=1,2,3,4,5,6;C. int a2 =1,2,3,4,5,6; D. int a2 =1,2,3,4; (5) A B9.The following statements ( )are correct. A.The individual elments are stored sequentially in an arrayB.For a single-dimensional array,the first element has an index of 0.C.If an array has been declared as consisting of 10 elments,the max index is 10.D. The size of an single-dimensional may be omitted when initializing values are included in the declaration statement (6) A B D 10.Given the piece of codeint a50;int *pa;pa=a; To access the 6th element of the array which of the following is correct?A. *(a+5) B. a5 C. pa5 D. *(*pa + 5) (6) A B C填空题1Write the result of following program:(_)main() float a=3.14; printf(“%f”,a); 3.1400002Write the result of following program:main() float a=5.23; printf(“%6.1f”,a); 5.23Suppose code segment: int k1,k2,k3,k4; scanf(“%d%d”,&k1,&k2); scanf(“%d,%d”,&k3,&k4);if we want k1,k3 get value 10, and k2,k4 get value 20, then the accurate input is_. 10 2010,204Write the result of following program:main() int k=11; printf(“k=%d,k=%o,k=%xn”,k,k,k);k=11,k=13,k=b5Suppose the following code segment: int m=0, n=0; char c=a; scanf(“%d%c%d”,&m,&c,&n); printf(“%d,%c,%d”,m,c,n);if input: 10A10 from keyboard, then the running result is_. 10,A,106In C, comments must begin with _ and end with _. /*, */7A C program, whatever its size, consists of _ and variables.functions8Read the following program and the result of it. Fill the blanks:main() int a=5; printf(“%dn”,_); result: 20 4*a 或 209In C, basic data types are int, char, float and _.double10The % operator can only be applied to data type _.int11Read the following program and the result of it. Fill the blanks:main() char c1,c2; c1=97; c2=98; _;result: c1=a,c2=bprintf(“c1=%c,c2=%c”,c1,c2);12An expression becomes a statement when it is followed by a _.semicolon (;)13sum=sum+3 can be written as _sum+=314Write the result of following program:(_)main() int p=30; printf(“%dn”,(p/30?p/10:p%3);313The correct expresson for 1x10 and 100x200 is _.(1=x=10) & (100=x=200)14Suppose the following code segment:int w=1,x=2,y=3,z=4,m; m=(wx)?w:x; m=(my)?m:y; m=(mz)?m:z;finally the value of m is _. 115Read the following program and the result of it. Fill the blanks.main() int _,b=2,c=3; if (c=a)printf(“%dn”,c); else printf(“%dn”,b);result: 12 a=116The following program decides whether the input is an odd number. Fill the blanks:main() int a; scanf(%d,&a); if (_) printf(this is an odd number);a%217The following program decides whether the input is an even number. Fill the blanks:main() int a; scanf(%d,&a); if (_) printf(this is an even number); !(a%2)18Read the following program. Fill the blanks:main() int x=1,y=0,a=0,b=0; switch(x) case 1:switch(y) case 0: a+; break; case 1: b+;break; case 2: a+;b+;break; case 3: a+;b+; printf(a=%d,b=%d,a,b);The running result is _. a=2,b=119Read the following program and the result of it. Fill the blanks:main() int p,a=5; if(p=a!=0) _;result: 12printf(%d ,p); 或 printf(“%d”, 1);20When we want to access functions included in mathematical function library,we should use the statements: _#include 21Write appropriate if statements for each of the following condition:if the x is less than 5,set the variable flag to 0,else set flag to 1.(_)if(x5) flag=0 else flag=1;22C language request in embeded if statement ,the use of else must be .与离它最近的上方的一个if匹配。23The function of following statements is : 。t=x; x=y; y=t交换变量x,y的值24Result of following program is int a=-1,b=4,k; k=(a=0)&(!(b-=0); printf(“%d%d%d%n”,k,a,b); 1 -1 325The pieces of program will convert a uppercase to lowercase and output.#includemain()char n,c; c=getchar() if (cA & cZ) n= ; printf(”%c”, n);else printf(“%c”, c ); c+32,c 26Write the result of following program:(_)main() int num=0; while(num=20)num+; printf(%d,num);2127Write the result of following program:(_)main() int count; count=2; for(; count=20;count+=3);printf(%d,count); 2328Fill appropriate

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论