《c programming》test paper

上传人:第*** 文档编号:32819604 上传时间:2018-02-12 格式:DOC 页数:6 大小:57.50KB
返回 下载 相关 举报
《c programming》test paper_第1页
第1页 / 共6页
《c programming》test paper_第2页
第2页 / 共6页
《c programming》test paper_第3页
第3页 / 共6页
《c programming》test paper_第4页
第4页 / 共6页
《c programming》test paper_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《《c programming》test paper》由会员分享,可在线阅读,更多相关《《c programming》test paper(6页珍藏版)》请在金锄头文库上搜索。

1、C ProgrammingTEST PAPERTime: 8:30-10:30 am. June 20, 2003Important note: your answers must be written on the answer sheetSection 1: Single Choice( 1 mark for each item, total 10 marks)1. 1. The precedence of operator _ is the lowest one.A0|y0) is equivalent to _.A!(x0)&!(y0) B!x0&!y0 C!x0|!y0 D!(x0)

2、|!(y0)4. 4. The value of expression _ isnt 0。A1/2 B!0 C!EOF DNULL5. 5. If x is a float variable, the value of expression (x=10/4) is _ 。A2.5 B2.0 C3 D26. 6. If variables are defined and assigned correctly, the expression _ is wrong.Aa&b Bab C&x Da, b7. 7. According to the declaration: int a10, *p=a;

3、 the expression _ is wrong.Aa9 Bp5 C*p+ Da+8. 8. _ is wrong.Achar str10; str=string; Bchar str =string;Cchar *p=string; Dchar *p; p=string;9. 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 void fun(int

4、 x) static int y;return;int z;void main( ) int a,b;fun(a);Ax, y Bx, y, z C a,b,y,z Da,b,x,y,z10. 10. According to the declaration: int p5, *a5; the expression _ is correct.Ap=a Bp0=a C*(a+1)=p Da0=2Section 2: Fill in the blanks( 2 mark for each item, total 30 marks)1. 1. According to the declaration

5、: int a234,the number of elements of array a is _.2. 2. Writing conditional expression_ to calculate the value of y.1 x0y= 0 x=0-1 xint f( ) static int k; return +k;void main( ) int k;for(k=0;kvoid p(int *x,int y) + *x;y=y+2;void main() int x=0, y=3;p(printf(%d, %d, x, y);15. 15. Writing the declara

6、tion _ with typedef, which makes CP a synonym for a character pointer array, 10 elements.Section 3: Read each of the following programs and answer questions (5 marks for each item, total marks: 30)1. 1. The output of the following program is _.#include void main( ) int k, x, s, t;x=3;s=0; t=x;for(k=

7、1; k, the output is _.#include void main( ) int j, k, sub, x;int a5; for(j=1; jvoid 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;wt=wt/10;4. 4. When input: 3 9 8 6 5 3 7 1 2 4 2 1 2 3 4, the output is _.#in

8、clude stdio.hvoid main( ) int flag,i,j,k,col,n,ri,a66;for(ri=1; ri=n)printf(a%d%d=%d#, i, col,aicol);flag=1;if(!flag) printf(NO#);5. 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;else if(word=0)word=1;if(ch=a)ch=ch-a

9、+A;putchar(ch);6. 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 void main() int count;char ch1,ch2;FILE *f1, *f2;if (f1 = fopen(a.txt,r) = N

10、ULL)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(%d#, count);break;if(ch1=?) count+;fclose(f1);fclose(f2);Section 4: Acco

11、rding to the specification, complete each program (2 mark for each blank, total: 30 marks)1If input is n(n0), calculate the value of s = 1/1! + 1/2! + 1/3! + + 1/n!.#include void main( ) int j, k, n;float f, s;scanf(%d, (1) ;for (k=1 ; k0), if its a prime number, print YES, otherwise print NO. (Prim

12、e numbers: an integral number not divisible without a remainder by any integral number other than itself and one. One isnt a prime number, but two is a prime number)。#include #include void main( )int n;int prime(int m);scanf(%d, if( (5) ) printf(YESn);elseprintf(NOn); int prime(int m) int i,n;if(m=1

13、) return 0;n=sqrt(m);for(i=2; istruct 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) ;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 工程造价

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号