教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 幼儿教育 >

浙江大学c程2002B试卷E

来源:网络收集 时间:2026-05-01
导读: 浙江大学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 ope

浙江大学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;

《C …… 此处隐藏:3558字,全部文档内容请下载后查看。喜欢就下载吧 ……

浙江大学c程2002B试卷E.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/38703.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)