版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、The C Programming Language EXAMINATION PAPERSemester: _ Spring _ Year: _2016_ BEIJING JIAOTONG UNIVERSITY Department: _School of Economics and Management _Class No: _2015_Class 1,2,3 _Student Name: _ _ Student ID: _ _ Important note: your answers must be written
2、60;on the answer sheet Section 1: Fill in the blanks(2 mark for each item, total 30 marks) 1.1 The value of expression 3>2>1 is _ 0_.1.2 The value of expression (doubl
3、e)(10/4) is_ 2.000000(2)_.1.3 What value is stored into the int variable b in each of the following? Assume that b and n are int variables with b containing 12 and n containing 5.b%=(n%=2) b=_0_.1.4 The output of the following statements is _ k=1 s=30_.int k=1
4、, s=0; switch (k) case 1: s+=10; case 2: s+=20; break; default: s+=3; printf("k=%d s=%d"
5、, k, s); 1.5 The following program fragment prints out _4_. int i; int f(int x) static int k = 0; x+=k+; return x; main( )i=f(2); i=f(3); printf(“%d”,i); 1.6
6、For the following recursive function f,function call f(2, '3', '2', '1'); will output_313212_.void f(int n, char a, char b, char c) if(n = 1) printf("%c%c", a, b); else f(n-1, a, c, b); printf("%c%c", a, b); f(n-1, c, b, a); return;1.7 The following
7、160;program prints out _5_. #include <stdio.h>#include <string.h> main() char st20=”hello0world!”; printf(“%dn”,strlen(st); 1.8 The following code fragment will output _0_.static int x, y, z;z = (x=1) | (y=2);printf("%d &q
8、uot;, y);1.9 The following code fragment will output _#_.main() int x; for (x=1; x<10; x+) if (x<3) continue; x*=2;printf(“#”); 1.10 The following code fragment will output _10_. m
9、ain() int array = 2, 8, 3, 11, 13, 2, 8, 2; int k; int total = 0; for ( k = 0; k < 8; k+ ) if (
10、160;array k % 2) break; total += array k; printf ( “%d ”, total ); Section 2: Single Choice(2 mark for each item, total 10 marks) 22.1 Which
11、 of the following words is reserved words (保留字) in C? BAabs Bchar Cstr Dsqrt2.2 _ACD都行_ is correct if it is used as a character constant. A B'080' C'n' D0xa 2.3 What is the byte
12、0;length of the string “tabcd”. AA6 B7 C8 D9 2.4 Assuming x = 10, the expression: x += 15*6 changes the valu
13、e of x to B A. 150 B. 100 C. 900 D.
14、 90 2.5 Determine the output of the following program. Cvoid main() int y=8,x=7; printf("%d %dn", +x, y+); A7,8 B9,7 C8,8 D8,92.6
15、 In the statement while(x=0), choose the equivalent expression for the x=0. BAx B!x Cx!=1 Dx<12.7 If x is a float variable, the value of expression (x=10/4) is _B_ 。 A2.5 B2.0 C3 D2 2.8 In order
16、160;to assign 45 to variant a and assign 64 to variant b with the statement scanf (“%d%d”, &a, &b), which input format is correct? DA45 64 B45,
17、60;64 C45;64 D4564 2.9 Supposing all the following variables are declared correctly, executing the statement “scanf("%d%c%f", &op1, &op, &op2);”,the values of op1, op and op2 are 1,* and 2.0 each when input_D_.A1.0*2 B1 * 2 C1.0*2.0D1*22.1
18、0 Write a expression for the following algebraic expression (3<y<9), which of the following expression is valid? C A3<y && y<9 B3<y | y<9 C3<y and y<9D3<y or y<92.11 Choose the wrong definition for the character strings. &
19、#160; CAchar str4= “QUST”; Bchar str= “QUST”; Cchar str2=Q, U,S, T ; Dchar str8= “QUST”; 2.12 What is the main problem with the following?_B_ main( )
20、0; int a10,i; for (i=0;i<10;i+) scanf (“%d”,ai); for (i=0;i<10;i+) ai= ai+1; ANothing is wrong. BLine is wrong.&
21、#160;C Line is wrong. D Both line and are wrong.2.13 Predict the output from: _A_ if (5 < 4) if (6 > 5) putchar('1'); else if (4
22、160;> 3) putchar('2'); else putchar('3'); putchar('4'); A 4 B 2 C 24 D 4 or 24, depending upon the implementation.2.14 As we know that a library
23、function double acos(double x) )1,1(-Îx which is include in “math.h”. Which one of the following works properly?_C/D_A #include “stdio.h” int y=acos(2); B #inlcude “math.h” int z;
24、0; z=acos(0.5); C #include “math.h” double y,x; y=acos(x); D #include “math.h” int x,z; z=acos(x=0.3);2.15 Which of the following Function declaration(函数声明)is valid? AAint f(int, float);
25、Bvoid f (int 3a); Cint f(int s6); Dvoid int(char a);2.16 According to the declaration: int a10, *p=a; the expression _D_ is wrong.Aa9 B*p+ Cp5 Da+2.17 In the following assignments or initialization, _
26、D_ is wrong. Achar s ="hello" Bchar *p; p="hello" Cchar *p="hello" Dchar s10; s="hello" 2.18 The running result of following program is( D ).include “stdio.h”main() struct person char
27、gender; int age; float score; student;printf(“%d”, sizeof(struct person) );A4 B5 C6 D72.19 If all variables have been defined and declared in the following program, all the variables which can be used in
28、160;function fun() are _A_ #include <stdio.h> void fun(int x) static int y; return;
29、 int z; void main( ) int a,b; fun(a); Ax, y Bx,
30、 y, z C a,b,y,z Da,b,x,y,z 2.20 When the file is closed successfully, the return value of function fclose is D .A-1 BTURE C0 D1Section 3: Read each of the following programs and answer questions (3 marks f
31、or each item, total marks: 6) 33.1 The output of the following program is _ 1 023 .#include <stdio.h> void main( ) long number,
32、wt, x; x=number=10230;wt=1; while(x!=0) wt=wt*10; x=x/10; wt=wt/10; while(number!=0)
33、printf("%dn", number/wt); number=number%wt; wt=wt/10; 3.2 The output of the following program is _ 123 .# include <stdio.h> int f( )
34、 static int k; return +k; void main( ) int k;&
35、#160; for(k=0;k<3;k+) printf("%d", f( ); Section 4: According to the specification, complete each program (2 mark for each blank, total: 30 marks) 44.1 Count the minimum of three number x,y,z, complete the blank in the program. main ( ) int x=4,y=5,z=8;int u,v; u = x<y ? x:y (1) v = u<z ? u:z (2) printf (“%d”,v); 4.2 A palindrome (回文)is a string that reads the same both forward
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年度河南省美容师职业资格中级模拟试卷及参考答案
- 2026年安全测评工程师考试实际操作技能题库及参考答案
- 2026年煤矿安全培训题库及参考答案
- 2026年税务政策知识题库(含答案)
- 2026年模拟导游考试题库及答案
- 2026年安全作业考试题库(含答案)
- 2026年标准员继续教育考试题库及答案
- 2026年江苏省大学生就业创业知识竞赛题库及答案
- 2026年萍乡学院辅导员招聘考试笔试题库带答案
- 2026年三甲医院培训考试题库及答案
- 浪潮存储AS520E操作手册
- 110KV变电站运营管理方案
- 中建办公、生活区临时设施专项施工方案
- 《土地经济学》课程教学大纲
- 氧气吸入操作评分标准(中心供氧)
- JC-T2723-2022预应力混凝土实心方桩
- 腹股沟斜疝的护理
- (21)-《计算机组成与结构》-华为-鲲鹏处理器
- 贵州玄德生物科技股份有限公司年产5000吨生态特色食品(4500L超临界CO2流体萃取)精深加工生产线建设项目环境影响报告
- 科学注塑成型技术
- BIM房地产BIM实施详细方案
评论
0/150
提交评论