浙江大学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;
相关推荐:
- [幼儿教育]【完整版】2019-2025年中国药物发现外
- [幼儿教育]2018-2019年初中信息技术广东初一竞赛
- [幼儿教育]最新外研版(一起)小学英语五年级上册《
- [幼儿教育]农业推广与创新管理专业 -中农大毕业论
- [幼儿教育]2017-2022年中国更年期用药行业市场深
- [幼儿教育]数学1.1.2第1课时棱柱、棱锥和棱台的结
- [幼儿教育]二年级群文阅读课例欣赏
- [幼儿教育]2010-2015年中国保险行业投资分析及深
- [幼儿教育]厄运打不垮的信念第一课时
- [幼儿教育]巧用文本,让表达在言语中绽放论文
- [幼儿教育]中学生百科知识竞赛题及答案
- [幼儿教育]八大菜系英文简介
- [幼儿教育]中国男装牛仔裤市场发展研究及投资前景
- [幼儿教育]远程数字视频监控系统在银行的应用
- [幼儿教育]光纤光缆制造工艺及设备
- [幼儿教育]国家安全法试题及答案
- [幼儿教育]2011高中提前招生及竞赛试题(物理卷1)
- [幼儿教育]宁夏第三产业房地产业、科学研究和技术
- [幼儿教育]中兴通讯 ME3000模块用户硬件设计手册_
- [幼儿教育]紫外线灯管的辐照强度问题
- 苏联东欧剧变的原因和历史教训浅析
- 人工智能导论实验报告(学生)
- 思科ITE章考试原题及答案
- 《学习雷锋好榜样》主题班会教案
- 加油站建设项目安全评价报告
- 剖析社保卡管理系统
- 2017-2018年影视剧新媒体版权运营行业
- 2017-2018学年四川省成都市高一上学期
- 2019最新高中数学 第三章 3.2.1 几类不
- 2011-2015年中国基酸市场调查及行业前
- 人教版新课标选修八Unit 1 课件Warming
- 郭溪燎原小学辅导学生记录表
- 教师资格证统考综合素质写作秘笈
- 国外校园绿色建筑研究方向与建设实践
- 15.1 动物运动的方式 课件(北师大版八
- 民用飞机空调系统
- 长安侠文化传统与唐诗的任侠主题
- 《中国近现代史纲要》名词解释
- 11金本《保险学概论》复习资料
- 民用建筑机电安装工程专业施工图图纸会




