2002B试卷E.pdf

上传人:赵** 文档编号:21123889 上传时间:2022-06-18 格式:PDF 页数:8 大小:180.10KB
返回 下载 相关 举报
2002B试卷E.pdf_第1页
第1页 / 共8页
2002B试卷E.pdf_第2页
第2页 / 共8页
点击查看更多>>
资源描述

《2002B试卷E.pdf》由会员分享,可在线阅读,更多相关《2002B试卷E.pdf(8页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、C ProgrammingC ProgrammingTEST PAPERTEST PAPERTime: 8:30-10:30 am. June 20, 2003Important note: your answers must be written on the answer sheetImportant note: your answers must be written on the answer sheetSection 1: Single ChoiceSection 1: Single Choice(1 mark for each item, total 10 marks1 mark

2、for each item, total 10 marks)1.The precedence of operator_is the lowest one.A0|y0)is equivalent to_.A !(x0)&!(y0)B!x0&!y0C!x0|!y0D!(x0)|!(y0)4.The value of expression _ isnt 0。A1/2B!0C!EOFDNULL5.If x is a float variable,the value of expression (x=10/4) is _ 。A2.5B2.0C3D26.If variables are defined a

3、nd assigned correctly, the expression _ is wrong.Aa&bBabC&xDa, b7.According to the declaration: int a10, *p=a; the expression _ is wrong.Aa9Bp5C*p+Da+8._ is wrong.Achar str10; str=string;Bchar str =string;Cchar *p=string;Dchar *p; p=string;9.If all variables have been defined and declared in the fol

4、lowing program, all the variableswhich can be used in function fun() are _.#include void fun(int x)static int y;return;int z;void main( )int a,b;fun(a);Ax, yBx, y, zC a,b,y,zDa,b,x,y,z10. According to the declaration: int p5, *a5; the expression _ is correct.Ap=aBp0=aC*(a+1)=pDa0=2C ProgrammingTEST

5、PAPER, June 20, 20031 /8Section 2: Fill in the blanksSection 2: Fill in the blanks(2 mark for each item, total 30 marks2 mark for each item, total 30 marks)1.According to the declaration: int a234,the number of elements of array a is _.2.Writing conditional expression_ to calculate the value of y.1x

6、0y=0 x=0-1x03.The value of expression1105is _.4.The value of expression(101)&4is_.5.The value of expressionsizeof(“hello”)is_.6.The output of the following statements is _.int k, s;for(k=1, s=0; k10; k+)if (k%2=0) continue;s += k;printf(k=%d s=%d, k, s);7.The output of the following statements is _.

7、#define MM(x,y)(x*y)printf(%d, MM(2+3,15);8.The output of the following statements is _.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 _.# include int f( )static int k;return +k;void main( )int k;for(k=0;k3;k+

8、)printf(%d#, f( );10. The output of the following program is _.f (int x)C ProgrammingTEST PAPER, June 20, 20032 /8if(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 _.int k=1, j=2, *p, *q, *t;p=&k; q=&j;t=p; p=q; q=t;printf(%d, %d,*p,

9、 k);12. The output of the following statements is _.int c =10, 30, 5;int *pc;for(pc=c; pcc+2; pc+)printf(%d#, *pc);13. The output of the following statements is _.char*st =ONE,TWO,FOUR,K;printf(%s, %cn, *(st+2), *st+1);14. The output of the following program is _.#include void p(int *x,int y)+ *x;y=

10、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 characterpointer array, 10 elements.Section 3: Read each of the following programs and answer questions (5 marks for eachSection 3: Read each of the following programs

11、and answer questions (5 marks for eachitem, total marks: 30)item, total marks: 30)1.The output of the following program is _.#include void main( )int k, x, s, t;C ProgrammingTEST PAPER, June 20, 20033 /8x=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 31 2 9 7 6 0,

12、the output is _.#include void main( )int j, k, sub, x;int a5;for(j=1; j=2; j+)for(k=0; k5; k+)scanf(“%d”, &ak);scanf(“%d”, &x);sub=-1;for(k=0; k5; k+)if(ak=x)sub=k;printf(%d#, sub);3.The output of the following program is _.#include void main( )long number, wt, x;x=number=10230;wt=1;while(x!=0)wt=wt

13、*10;x=x/10;wt=wt/10;while(number!=0)printf(%d#, number/wt);number=number%wt;wt=wt/10;C ProgrammingTEST PAPER, June 20, 20034 /84.When input:39 8 6 5 3 7 1 2 421 2 3 4, the output is _.#include stdio.hvoid main( )int flag,i,j,k,col,n,ri,a66;for(ri=1; ri=2; ri+)scanf(%d,&n);for(i=0; in; i+)for(j=0; jn

14、; j+)scanf(%d,&aij);flag=0;for(i=0; in; i+)col=0;for(j=0; jn; j+)if (aicolaij)col=j;for (k=0; kn; k+)if(aicol=n)printf(a%d%d=%d#, i, col,aicol);flag=1;if(!flag)printf(NO#);5.When input:how are you? , the output is _.#include void main( )int word;char ch;word=0;while(ch=getchar()!=?)if(ch= ) word=0;e

15、lse if(word=0)word=1;if(ch=a)ch=ch-a+A;C ProgrammingTEST PAPER, June 20, 20035 /8putchar(ch);6.If the following data are stored in text file a.txtone?two?1234?output?And the following data are stored in text file b.txtone?two?1204?input?The output of the following program is _.# include # include vo

16、id main()int count;char ch1,ch2;FILE *f1, *f2;if (f1 = fopen(a.txt,r) = NULL)printf(Cant open file : %sn, a.txt);exit(0);if (f2 = fopen(b.txt,r) = NULL)printf(Cant open file : %sn, b.txt);exit(0);count=0;while (!feof(f1)|!feof(f2)ch1=fgetc(f1);ch2=fgetc(f2);if(ch1!=ch2)printf(%c#%c#,ch1,ch2);printf(

17、%d#, count);break;if(ch1=?) count+;fclose(f1);fclose(f2);Section 4: According to the specification, complete each program (2 mark for each blank,Section 4: According to the specification, complete each program (2 mark for each blank,C ProgrammingTEST PAPER, June 20, 20036 /8total: 30 marks)1If input

18、 is n(n0), calculate the value ofs = 1/1! + 1/2! + 1/3! + + 1/n!.#include void main( )int j, k, n;float f, s;scanf(%d, &n);(1);for (k=1 ; k0), if its a prime number, print YES, otherwise print NO. (Prime numbers:an integral number not divisible without aremainder by any integral number other thanits

19、elfand one. One isnt a prime number, but two is a prime number)。#include #include void main( )int n;int prime(int m);scanf(%d, &n);if(5)printf(YESn);elseprintf(NOn);int prime(int m)int i,n;if(m=1) return 0;n=sqrt(m);C ProgrammingTEST PAPER, June 20, 20037 /8for(i=2; i=n; i+)if(6) return(7);(8);3The

20、definition of function f2 () is equivalent to the definition of function f1 ().int f1(char s )int f2(char *s)int k=0;char *ss;while(sk!=0)(9);k+;while(*s+!=(10)return k;return(11);4When input is the names and scores of 30 students, print the name and score of the studentwho have the highest score.#i

21、nclude struct studentchar name10;int score;void main( )int k;struct student s30, *ptr;struct student *f(struct student *stud, int n);for(k=0; kname, ptr-score);struct student *f(struct student *stud, int n)struct student * pmax, *p;(13);for(p=stud; pscore pmax-score)(14);return(15);C ProgrammingTEST PAPER, June 20, 20038 /8

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com