试卷代号:1253 座位号■■ 中央广播电视大学2008一2009学年度第二学期“开放本科”期末考试 C语言程序设计A试题 2009年7月 题 号 二 三 四 五 总分 分 数 得 分 评卷人 一、单选题(每小题2分,共20分) 1.由C语言源程序文件编译而成的目标文件的缺省扩展名为()。 A.cpp B.c C.exe D.obj 2.设x和y均为逻辑值,则×川y为假的条件是( )。 A.它们均为真 B.其中一个为真 C.它们均为假 D.其中一个为假 3.枚举类型中的每个枚举常量的值都是一个( )。 A.整数 B.浮点数 C.字符 D.记录 4.循环语句“for(i=0;i<=n;i十十)S;”中循环体S被执行的次数为( )。 A.1 B.n-1 C.n D.n+1 5.假定有定义为"inta[4][5]=(1,3,5},{2,8)};",则a[1][1]的值为()。 A.3 B.5 C.2 D.8 6.在下面的选项中,不能作为函数的返回类型的是( )。 A.void B.int C.new D.long 1349
试卷代号:1253 座位号口习 中央广播电视大学2008-2009学年度第二学期“开放本科”期末考试 C语言程序设计 A 试题 2009年 7月 题 号 四 五 总 分 分 数 得 分 评卷人 一、单选题(每小题 2分 ,共 20分} 1.由 C语言源程序文件编译而成的 目标文件的缺省扩展名为( )。 A. cpp B. c C. exe D. obj 2.设 x和y均为逻辑值,则 x」!y为假的条件是( )。 A.它们均为真 B.其中一个为真 C.它们均为假 D.其中一个为假 3.枚举类型中的每个枚举常量的值都是一个( )。 A.整数 B.浮点数 C.字符 D.记录 4.循环语句“for(i=0; 1<-n; i十+)5;”中循环体S被执行的次数为( A.1 B. n一 1 C. n D. n十 1 5.假定有定义为”int a仁4][5〕二{{1,3,5},{2,8}};",则 a[1]仁1]的值为( A.3 B. 5 C. 2 D. 8 6.在下面的选项中,不能作为函数的返回类型的是( )。 A.void B. int C. new D. long 1349
7.假定x的值为5,y的值为6,则表达式x十十一一y的值为()。 A.25 B.30 C.36 D.42 8.用calloc函数创建具有10个整型元素的动态存储空间正确调用是()。 A.calloc(10,sizeof(char)) B.calloc(10) C.calloc(10,sizeof(int)) D.calloc(20,sizeof(int)) 9.假定有定义“intb[10],pb;”,则不正确的赋值为()。 A.pb=b B.pb=b[5] C.pb=b+2 D.pb=&b[0] 10.标准输人设备的文件流标识符是( )。 A.stderr B.stdin C.stdout D.stdio 得 分 评卷人 二、填空题(每小题2分,共26分) 1.执行“printf("%c",’A’+2);”语句后得到的输出结果为 2.short int类型的长度为 3.用类型关键字表示十进制常数3.26f的类型为 4.假定y=10,则表达式+十y*3的值为 0 5.逻辑表达式(x==0&&y>5)的相反表达式为 6.若x=5,y=10,则x!=y的逻辑值为 7.假定二维数组的定义为“inta[3][5];”,则该数组所占存储空间的字节数为 8.使用“typedef char BB[10][50];”语句定义 为含有10行50列的二维字符数 组类型。 9.字符串"”a:xxk数据"的长度为 10.假定p所指对象的值为25,p+1所指对象的值为46,则*++p的值为 11.假定一个数据对象为it类型,则指向该对象的指针类型为 12.假定一个结构类型的定义为“struct A{inta,b;Ac;};”,则该类型的长度为 13.假定要访问一个结构对象×中的数据成员a,则表示方式为 1350
7.假定 x的值为 5,y的值为 6,则表达式 x+十,一一y的值为( )。 A.25 B. 30 C. 36 D. 42 8.用 calloc函数创建具有 10个整型元素的动态存储空间正确调用是( ) A. calloc(10,sizeof (char)) B. calloc(10) C. calloc(10,sizeof(int)) D. calloc(20,sizeof(int)) 9.假定有定义“int b[10], * pb;",则不正确的赋值为( )。 A. pb=b B. pb=b[5] C. pb二b+2 D. pb=&b[0] 10.标准输人设备的文件流标识符是( )。 A. stderr B.stdin C. stdout D. stdio 得 分 评卷人 二、填空题(每小题 2分,共 26分) 1.执行“printf (" %c",' A’十2);”语句后得到的输出结果为_ 。 2. short int类型的长度为 3.用类型关键字表示十进制常数3. 26f的类型为_ 。 4.假定 y=10,则表达式+十y*3的值为 5.逻辑表达式(x=二。&&y>5)的相反表达式为 6.若x=5, Y=10,则x!二y的逻辑值为_ 。 7.假定二维数组的定义为“inta[3][5];",则该数组所占存储空间的字节数为 8.使用“typedef char BB[10][50];”语句定义_ 为含有10行50列的二维字符数 组类型。 9.字符串“a八\xxk\\数据”的长度为 16.假定p所指对象的值为25,p十1所指对象的值为46,则,十+p的值为_ 。 11.假定一个数据对象为 int,类型,则指向该对象的指针类型为 12.假定一个结构类型的定义为 “struct A {int a, b; A 。;};”,则该类型的长度为 13.假定要访问一个结构对象x中的数据成员a,则表示方式为_ 。 1350
得分 评卷人 三、写出下列每个程序运行后的输出结果(每小题6分,共30分) 1.include<stdio.h void main(){ int i,s=0; for(i=1;;i++){ if(s>30)break; if(i%2==0)s+=i; printf("s=%d\n",s); } 2.include<stdio.h void main(){ inta[9]=(36,25,48,24,55,40,18,66,20}: int i,bl,b2; b1=b2=a[o]; for(i=1;i<9;i++)( if(a[i]>b1)bl=aCi]; if(a[i门<b2)b2=a[i]; } printf("%d %d\n",bl,b2); } 3.include<stdio.h> void SB(char ch){ switch(ch)( case’A':case’a': printf("WW");break; case 'B':case 'b': 1351
得 分 评卷人 三、写出下列每个程序运行后的输出结果(每小题 6分,共 30 1. #include< stdio. h> void main( ){ int i,s= 0 for(i二1;;i+十){ if(s>30) break; if(i%2==0) s+=i; } printf("s= 0 o d\n", s) 2.#include< stdio. h> void main() int a[9]={36,25,48,24,55,40,18,66,20}; int i,bl,b2; bl= b2= for(i=1 a[0]; i<9;i++){ if(a[i]>bl) bl=a[i]; if(a[i]<b2) b2=a[i]; } printf ("% d 0 o d\ n,bl,b2) 3.#include<stdio. h> void SB(char ch){ switch(ch){ case 'A':case,a': printf ("W W”);break case 'B':case 'b':
printf("GG");break; default: printf("BB");break; void main(){ char al='a',a2='B',a3='f'; SB(al);SB(a2);SB(a3); printf(™n"; } 4.include<stdio.h define M6 void main() { int i,x; inta[0={10,15,22,37,46,58}; for(i=0;iKM/2;i++){x=a[i];a[i]=a[M-1-i门;a[M-1-i订=x;} for(i=0;<;++)printf("%d",a[i]); printf("\n"); } 5.include<stdio.h struct Worker{ char name[15];int age;float pay; }: void main(){ struct Worker x=("wanghua",52,2350); struct Worker y,p; y=x;p=&x; printf("%d %7.2f\n",y.age+p->age,p->pay+20); 1352
printf ("GG“);break default: printf ("BB“);break; ) } void main(){ char al“'a',a2='B',a3二,f' SB(al);SB(a2);SB(a3); printf("\n"); } 4.#include<stdio. h> #define M 6 void main( ) int i, x; int a仁M]={10,15 fore=O; for(i=0; K M/2 22,37,46,58); i++){ x=a[i];a[i]=a[M一1一1〕;a仁M-1一i]=x i<6;i++)print("ood ",aEi]); printf("\n"); 5.#include<stdio. h> struct W orker char name[15];int age; float pay; void main() struct Worker x= {"wanghua', 52,2350}; struct Worker y, * p y二x; P=&x printf("%d 007. 2f\n", y. age+p一>age,p一>pay+20) 1352
得分 评卷人 四、写出下列每个函数的功能(每小题6分,共12分) 1.int FH()( int x,y=0; scanf("%d",&x); while(x!=-l){y+=x;scanf("%d",&x);》 return y; } 函数功能: 2.int FF(struct IntNode *f) /任为指向一个单链表的表头指针 int n=0; if(!f)return 0; while(f)( n十十 f=f->next; } return n; 假定struct IntNode的类型定义为: struct IntNode int data;struct IntNode next;); 函数功能: 1353
得 分 评卷人 四、写出下列每个函数的功能(每小题 6分,共 12分) 1. int FH() int x,y=0; scanf("oo了,&x); while(x!二一1){y+=x; scanf("%d‘, &x); return y; 函数功能: 2. int FF(struct IntNode * f) //f为指向一个单链表的表头指针 int n= 0 if(!f) return 0; while(f) n十 + f=f一>next; return n 假定struct IntNode的类型定义为: struct IntNode{int data;struct IntNode * next; 函数功能: 1353