版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医药公司质量管理员试题及答案
- 牛奶安全生产宣传讲解
- 2025年城市智慧能源管理系统建设
- 镇江工地食堂外包合同
- 逆向成型制作外包合同
- 艺术教师培训外包合同
- 医院外科消毒包外包合同
- 天然气公司挖沟外包合同
- 企业与个人劳务外包合同
- 电商打包业务外包合同
- 2026年宁夏电投永利能源有限公司公开招聘考试模拟试题及答案解析
- 2026广东佛山市禅城区祖庙街道公有企业招聘初试笔试历年参考题库附带答案详解
- 《预算执行常态化监督发现问题纠偏整改操作指南(试行)》
- T-CCSAS 062-2026《行为安全观察与沟通实施指南》
- 2026年部编版语文五年级下册期末考试真题及答案(共3份)
- 物业工程安全管理培训(设备安全篇)
- 树仔菜种植技术
- 2025-2030无人船研发行业市场供需分析及智能航海前景评估研究规划报告
- 南通市中考英语真题精解2024
- 法务风险防控操作指南(标准版)
- 2026秋招:贵州遵钛集团试题及答案
评论
0/150
提交评论