山东师范大学10-11电子C语言期末试题 下载本文

内容发布更新时间 : 2024/5/18 10:23:04星期一 下面是文章的全部内容请认真阅读。

日 - -- - --月--- - -- - 年---- -- -- - -- - -- - -- - :---间---时--试---考--- - -- - --- -- - -- - --- -- - 线- - - --业- 专--- -- -- - -- - -- - -- - 封 --)-部---(---院--- -- - -- - -- 密 - --- --名-姓--- --- -- - -- - --- -- - -- - --- -- - -- - -- - -- - 号----学-山东师范大学2010-2011学年第1学期期末考试试题

(时间:120分钟 共100分)

课程编号:080920201、080940201 课程名称:C语言程序设计 试题类别: A考试类型:闭卷

适用年级:2010 适用专业:电子信息工程、电子科学与技术 题号 I II III 总分 阅卷人 复核人 得分

Part Ⅰ

For each of the following questions, fill-in one of either: A, B, C, or D on the blanks. (There are 15 questions, each of which is worth 2 mark.total 40.)

得 分 评阅人 1. ( ) 2. ( ) 3. ( ) 4. ( ) 5. ( ) 6. ( ) 7. ( ) 8. ( ) 9. ( ) 10. ( ) 11. ( ) 12. ( ) 13. ( ) 14. ( ) 15. ( ) 16. ( ) 17. ( ) 18. ( ) 19. ( ) 20. ( )

1. If x is a float variable, the value of expression (x=10/4) is _____ 。

A) 2.5 B) 2.0 C) 3 D) 2

2. If variables are defined and assigned correctly, the expression ______ is wrong.

A) a&b B) a^b C) &&x D) a, b

3. According to the declaration: int a[10], *p=a; the expression ______ is wrong.

A) a[9] B) p[5] C) *p++ D) a++ 4. ______ is wrong.

A) char str[10]; str=\ B) char str[ ]=\ C) char *p=\ D) char *p; p=\5. The precedence of operator _____ is the highest one.

A) += B) [] C) & D) ++ 6. The valid C expression of mathematical expression 1≤x≤5 is .

A) 1<=x<=5 B) (x> =1)&(x<=5 ) C) (x>=1 )&&(x<=5) D) (1 < =x)||(5> =x) 7. Which one of following marks can be defined as identifier?

A) int B)float C) char D)string

8.Having declaration statement: int a=1, b=2, c=3; the value of expression

(a>b>c,a

A) 0 B)1 C) 2 D) 3

9. Given the following declarations of arrays, which one is valid.

A) char str[30]= {12,23,34}; B) int a[ ] ; C) int x[4] [ ]; D) int x[ ][5]; 10. data type of variable f and i:

float f=3.14; int i;

which expression of following is legal.

A) i=(int)f%5 B) i=int(f)%5 C) i=f%5 D) i=(int f)%5

11. Which one of following marks can be defined as identifier?

A) main B) _0 C)void D) sizeof

12. Having initialization: int a=6,b=5,c=8,d=7,m=2,n=2; the value of m and n after executed the expression (m=c

A) 0 0 B) 0 2 C) 0 1 D) 2 2

13. Having declaration statement:char s[]=\

The value of a is

A) 7 B)8 C) 13 D) 11 14. while((ch=getchar()) ==’e’) printf(“*”);

Having inputted abcde, The number of * outputted is A) 0 B)1 C)2 D) 3 15. The following is a segment of a program: int a[10]={0,1,2,3,4,5,6,7,8,9},*p=&a[3],b; b=p[5]; The value of b is A) 6 B) 7 C) 8 D) 9

16. 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

17. Fill in the blank and complete the following function used to calculate the sum of two integers, and return the result by formal parameter. void func(int x,int y, ) { *z=x+y; }

A) int *z B) int z C) &z D)int &z

18. What will be output after execution of following programming?

main()

{ char s[]=\ printf(\ printf(\ }

A) 13 B) 23 C) 16 D) 26 19. What will be output after execution of following programming?

main(){int i,j; char a[ ]=”Excellent!”; a[5]=0;i=sizeof(a); j=strlen(a); printf(“%d,%d\\b”,i,j); }

A) 5,11 B) 6,11 C) 10,6 D) 11,5 20. What will be output after execution of following programming?

main()

{ int x=5,a=0,b=0;

switch(x){ case 0:a++; break; case 1:b++; break; case 2:a++; break; } printf(“a=%d,b=%d\\n”,a,b); }

A) a=2,b=1 B) a=1,b=1 C) a=1,b=0 D) a=0,b=0 Part Ⅱ

Consider the following programs and write what will be output after execution (There are 10 questions, each of which is worth 5 marks. total 50.)

1

得 分 评阅人 1. main() { int a, b; for(a=1, b=1; a<=100; a++) { if(b>=10) break ; if (b%3==1) { b+=3; continue; } } printf(“%d\\n”,a); } 2.

#include \#include \main()

{ int digit, sum=0, num=1234; while(num!=0) {

digit=num; num=num/10; sum+=digit; }

printf(\} 3. main() { int a=15,b=21,m=0; switch(a%3) { case 0:m++;break; case 1:m++; } switch(b%2) { default:m++; case 0:m++;break;} printf(\}

4.

#define MAX(x,y) (x)>(y)?(x):(y) main()

{ int a=5,b=2, c=3,d=3,t; t=MAX(a+b,c+d) *10; printf(“%d\\n”,t); } 5.

#include main()

{ int k=0,*ps, a[11]={ 1,2,3,4,5,6,7,8,9,10}; for(ps=a;*ps!=0; ps+=2) k+=*ps;

printf(“%d\\n”,k); } 6.

#include #include main()

{ char *s=“Henan”, *ss=”Hebei”;

strcmp(ss, s)<0? printf(“%s”,ss): printf(“%s”,s);} 7.

#include

void move(char *str, int n) { char temp ; int i;

temp=str[0];

for(i= 1; i

} main()

{ char s[]=”abcdef”;

int i, z; int n=3; z=strlen(s);

for(i=1; i<=n; i++) move(s,z); printf(\

}

2

8.

#include int ff(int n) {

static int f=1; f=f*n; return f; }

main() {

int i;

for(i=1;i<5;i++)

printf(\} 9.

#include \main() {

int a[2][3]={11,23,6,89,45,23}; int (*pa)[3]; pa=a;

printf( \}

#include #include main()

{ char a[][10]={“morning”,”afternoon”,”evening”},*pa[3]; int i;

pa[0]=a[0]; pa[1]=a[1]; pa[2]=a[2];

for(i=0;i<3;i++){

printf(“Good ”);

printf(\ printf(\n\!’ ); } }

Part Ⅲ

(There are 1 questions, worth 10 marks.)

得 分 评阅人 Write a function can be called to find the value and position of largest element in the two-dimensional array given by main function. #include main() {

int a[4][3]={{13, 24, 35}, {3, 76, 78}, {91, 0, 151}, {12, 63,108}};

3