2014年计算机二级C语言考试上机模拟试题(3)_第4页

考试站(www.examzz.com)   【考试站:中国教育考试第一门户】   2014年2月10日
31.若有以下定义和语句: 
char s [10]="abcd!",*s2="\nl23\\"; 
Drintf("%d%d\n",strlen(sl),strlen(s2)); 
则输出结果是(  )。 
A.5 5 
B.10 5 
C.10 7  
D.5 8 
 32.有以下程序: 
#include 
#define N 8 
 void fun(int*x,int i) 
{*x=*(x+i);) 
main(  ) 
{ int a[N]={1,2,3,4,5,6,7,8},i; 
fun(a,2); 
for(i=0;i{printf("Ha",a[i]);} 
printf("\n"); 
) 
程序运行后的输出结果是(  )。 
A.1313 
B.2234 
C.3234  
D.1234 
33.有以下程序: 
#include 
int f(int t[],int n); 
main(  ) 
{int a[4]={1,2,3,4},s; 
s=f(a,4);printf("%d\n",s); 
int f(int t[],int n) 
{if(n>0)return t[n-1]+f(t,n-1); 
else return 0; 
) 
程序运行后的输出结果是(  )。 
A.4 
B.10 
C.14 
D.6 
34.有以下程序: 
#include 
int fun(  ) 
{static int x=1; 
X*=2;return X; 
main(  ) 
{int i,S=1; 
for(i=1;i<=2;i++)s=fun(  ); 
printf{¨%d\n",s); 
) 
程序运行后的输出结果是(  )。 
A.0 
B.1 
C.4  
D.8 
35.有以下程序: 
#include 
#define SUB(a)(a)-(a) 
main(  ) 
{int a=2,b=3,c=5,d; 
d=SUB(a+b)*C; 
printf("%d\n",d); 
) 
程序运行后的输出结果是(  )。 
A.0 
B.-l2 
C.-20 
D.10 
36.设有定义: 
struet complex 
{int real,unreal;)datal={1,8},data2; 
则以下赋值语句中错误的是(  )。 
A.data2=datal; 
B.data2={2,6}; 
C.data2.real=datal.real; 
D.data2.real=datal.unreal; 
37.有以下程序: 
#include 
#include 
struct A 
{int a;char b[10];double C;); 
void f(struct A t); 
main(  ) 
{struct A a={"1001,"ZhangDa",l098,0}; 
f(a);printf("%d,%S,%6.1f\n",a.a,a.b,a.c);} 
void f(struct A t) 
{t.a=1002;strcpy(t.b,"ChangRon9");t.c=1202.0;} 
程序运行后的输出结果是(  )。 
A.1001,ZhangDa,1098.0 
B.1002,ChangRong,1202.0 
C.1001,ChangRong,1098.0  
D.1002,ZhangDa,1202.0 
38.有以下定义和语句: 
struct workers 
{int num;char name[20];char C; 
struct 
(int day;int month;int year;)S; 
}; 
struct workers w,*pw; 
pw=&w; 
能给w中year成员赋1980的语句是(  )。 
A.*pw.year=1980; 
B.w.year=1980; 
C.pw->year=1980  
D.w.S.year=1980; 
39.有以下程序: 
#include 
main(  ) 
{int a=2,b=2,C=2; 
print{("%d\n",a/b&c); 
} 
程序运行后的输出结果是(  )。 
A.0 
B.1 
C.2 
D.3 
40.有以下程序: 
#include 
main(  ) 
{FILE*fp;char str[10]; 
fp=fopen("myfile,dat",""); 
{puts("abe",ip);fclose(fp); 
fp=fopen("myfile.dat","a*"); 
fprintf(fp,"%d",28); 
rewind(fp); 
fscanf(fp,"%S",str);puts(str); 
fclose(fp); 
} 
程序运行后的输出结果是(  )。 
A.abc 
B.28c 
C.abc28  
D.内类型不一致而出错 

相关文章