浙江大学c程2002B试卷E
浙江大学c程2002B试卷E
《C Programming》TEST PAPER
Time: 8:30-10:30 am. June 20, 2003
Important note: your answers must be written on the answer sheet
Section 1: Single Choice(1 mark for each item, total 10 marks)
1. The precedence of operator _____ is the lowest one.
A.<< B.!= C.&& D.=
2. _____ is wrong if it is used as an integer constant.
A.0xa B.010L C.10 D.1.0
3. The expression !(x>0||y>0) is equivalent to _____.
A.!(x>0)&&!(y>B.!x>0&&!y>0 C.!x>0||!y>0 D.!(x>0)||!(y>0)
0)
4. The value of expression ______ isn’t 0。
A.1/2 B.!’\0’ C.!EOF D.NULL
5. If x is a float variable, the value of expression (x=10/4) is _____ 。
A.2.5 B.2.0 C.3 D.2
6. If variables are defined and assigned correctly, the expression ______ is wrong.
A.a&b B.a^b C.&&x D.a, b
7. According to the declaration: int a[10], *p=a; the expression ______ is wrong.
A.a[9] B.p[5] C.*p++ D.a++
8. ______ is wrong.
A.char str[10]; str="string"; B.char str[ ]="string";
C.char *p="string"; D.char *p; p="string";
9. If all variables have been defined and declared in the following program, all the variables
which can be used in function fun() are ______.
#include <stdio.h>
void fun(int x)
{ static int y;
……
return;
}
int z;
void main( )
{ int a,b;
fun(a);
……
}
A.x, y B.x, y, z C. a,b,y,z D.a,b,x,y,z
10. According to the declaration: int p[5], *a[5]; the expression ______ is correct.
A.p=a B.p[0]=a C.*(a+1)=p D.a[0]=2
《C Programming》TEST PAPER, June 20, 2003 1 /8
浙江大学c程2002B试卷E
Section 2: Fill in the blanks(2 mark for each item, total 30 marks)
1. According to the declaration: int a[2][3][4],the number of elements of array a is ___24__.
2. Writing conditional expression___(x>0)?1: (x==0)? 0:-1___ to calculate the value of y. 1 x>0
y= 0 x=0
-1 x<0
3. The value of expression 1<10<5 is __1___.
4. The value of expression ~(10<<1)&4 is___0___.
5. The value of expression sizeof(“hello”) is___6___.
6. The output of the following statements is __k=10,s=25___.
int k, s;
for(k=1, s=0; k<10; k++){
if (k%2==0) continue;
s += k;
}
printf("k=%d s=%d", k, s);
7. The output of the following statements is __47___.
#define MM(x,y) (x*y)
printf("%d", MM(2+3,15));
8. The output of the following statements is __k=1 s=30___.
int k=1, s=0;
switch (k) {
case 1: s+=10;
case 2: s+=20; break;
default: s+=3;
}
printf("k=%d s=%d", k, s);
9. The output of the following program is __1#2#3#___.
# include <stdio.h>
int f( )
{ static int k;
return ++k;
}
void main( )
{ int k;
for(k=0;k<3;k++)
printf("%d#", f( ));
}
10. The output of the following program is __5___.
《C Programming》TEST PAPER, June 20, 2003 2 /8
浙江大学c程2002B试卷E
f (int x)
{
if(x<=1) return 1;
else return f(x-1)+f(x-2);
}
void main( )
{ printf("%d", f(4));
}
11. The output of the following statements is __2, 1___.
int k=1, j=2, *p, *q, *t;
p=&k; q=&j;
t=p; p=q; q=t;
printf("%d, %d",*p, k);
12. The output of the following statements is __10#30#___.
int c[ ]={10, 30, 5};
int *pc;
for(pc=c; pc<c+2; pc++)
printf("%d#", *pc);
13. The output of the following statements is ___FOUR, P__.
char *st[ ]={"ONE","TWO","FOUR","K"};
printf("%s, %c\n", *(st+2), **st+1);
14. The output of the following program is __0, 4___.
#include <stdio.h>
void p(int *x,int y)
{ ++ *x;
y=y+2;
}
void main()
{ int x=0, y=3;
p(&y, y);
printf("%d, %d", x, y);
}
15. Writing the declaration _____ with typedef, which makes CP a synonym for a character
pointer array, 10 elements. typedef char *CP[10];
Section 3: Read each of the following programs and answer questions (5 marks for each item, total marks: 30)
1. The output of the following program is __33#366#3699#___.
#include <stdio.h>
void main( )
{ int k, x, s, t;
《C Programming》TEST PAPER, June 20, 2003 3 /8
浙江大学c程2002B试卷E
x=3;
s=0; t=x;
for(k=1; k<=3; k++){
t=t*10+x;
s=s+t;
printf("%d#", s);
}
}
2. When input: 7 3 0 3 0 3 1 2 9 7 6 0<ENTER>, the output is ____3#-1#___.
#include <stdio.h>
void main( )
{ int j, k, sub, x;
int a[5];
for(j=1; j<=2; j++){
for(k=0; k<5; k++)
scanf(“%d”, &a[k]);
scanf(“%d”, &x);
sub=-1;
for(k=0; k<5; k++)
if(a[k]==x) sub=k;
printf("%d#", sub);
}
}
3. The output of the following program is __1#0#2#3#___.
#include <stdio.h>
void main( )
{ long number, wt, x;
x=number=10230;
wt=1;
while(x!=0){
wt=wt*10;
x=x/10;
}
wt=wt/10;
while(number!=0){
printf("%d#", number/wt);
number=number%wt;
相关推荐:
- [实用文档]李践-有效提升销售的12大黄金法则8-大
- [实用文档]党支部换届工作方案
- [实用文档]2013年下期电子商务专业部宣传工作计划
- [实用文档]方庄一矿通风、钻探绩效工资考核管理办
- [实用文档]项目一 认识企业物流认识企业物流
- [实用文档]MBI_Display_产品蓝图规画
- [实用文档]北京市建筑业劳务作业人员普法维权培训
- [实用文档]锅炉燃烧调整与运行优化
- [实用文档]4支付结算业务的核算
- [实用文档]米什金_货币金融学_第9版各章学习指导
- [实用文档]水泥混凝土路面硬化工程施工组织设计
- [实用文档]钢筋工程安全技术交底书
- [实用文档]关于公布华中师范大学本科毕业论文
- [实用文档]太原市园林绿化施工合同范本 2
- [实用文档]周日辅导 初中英语分类复习单项选择题(
- [实用文档]第四章 文化经纪人的管理形式 第二节
- [实用文档]学宪法讲宪法竞赛题库
- [实用文档]《数值计算方法》期末考试模拟试题二
- [实用文档]爱词霸学英语:每日一句( 十月)
- [实用文档]2014年国家公务员面试:无领导小组讨论
- 新课程主要理念和教学案例分析汇编(24
- 英国人的快乐源于幸福的家庭生活
- 七年级上册第一次月考模拟数学试卷
- 真丝及仿真丝的种类有哪些?
- 【最新】华师大版八年级数学下册第十六
- 高中英语3500个必背单词
- 我可以接受失败,但我不能接受放弃!
- 最近更新沪科版八年级物理上册期末试卷
- 绿化工作先进乡镇事迹材料
- 鲁教版九年级上册思想品德教学计划
- 英语音标的分类
- 地下室底板无梁楼盖与普通梁板结构形式
- 美容师黄金销售话术
- 雅思写作满分作文备考方法
- 血清甲状腺激素测定与高频彩色多普勒超
- 1度浅析装修对室内空气品质的影响
- 2017-2022年中国汞矿行业深度分析与投
- 计算机二级VB公共基础知识
- (何勇)秸秆禁烧_重在寻找出路
- 内外墙抹灰工程分包施工合同1




