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

时间:2023-11-06 15:30:11 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。




- -- - ----- - -- - ---- -- -- - -- - -- - -- - -------------- - -- - --- -- - -- - --- -- - 线- - - ---

--- -- -- - -- - -- - -- - ------------ -- - -- - -- - --- ------ --- -- - -- - --- -- - -- - --- -- - -- - -- - -- - -----山东师范大学2010-2011学年第1学期期末考试试题

(时间:120分钟 100分)

课程编号:080920201080940201 课程名称: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="string"; B) char str[ ]="string"; C) char *p="string"; D) char *p; p="string"; 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

8Having 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[]="\123\\100a\t"; int a=sizeof(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[]="136", *p= s; printf("%c",*p++); printf("%c",*++p); }

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) 511 B) 611 C) 106 D) 115 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 "stdio.h" #include "conio.h" main()

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

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

printf("%d ", sum); } 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("%d\n",m); }



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 str[i-1]=str[i]; str[n-1]=temp;

} main()

{ char s[]=”abcdef”;

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

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

}

2


本文来源:https://www.wddqw.com/doc/83fb92da76eeaeaad1f3300a.html