首页 > 职业资格  > 

全国计算机二级c语言上机题库附答案(2)

2023-02-05   来源:万能知识网

23.有以下程序:

#include


(资料图片)

main()

{ rhar a=’H’;

a=(a>=’A’&&a<=’2’)?(a-’A’+’a’):a;

printf("%c\n",a);

}

程序运行后的输出结果是( )。

A.A

B.a

C.H

D.h

24.有以下程序:

#include

int f(int x);

main()

{ int a,b=0;

for(a=0;a<3;a++)

{b=b+f(a);putchar(’A’+b);}

}

int f(int x)

{ return x * xl; }

程序运行后的输出结果是( )。

A.ABE B.BDI C.BCF D.BCD

25.设有定义:int x[2][3];,则以下关于二维数组X的叙述错误的是( )。

A.x[0]可看做是由3个整型元素组成的一维数组

B.x[0]和x[l]是数组名,分别代表不同的地址常量

C.数组X包含6个元素

D.可以用语句x[o]=0;为数组所有元素赋初值0

26.设变量P是指针变量,语句P=NULL;是给指针变量赋NULL值,它等价于( )。

A.p="";

B.p="0";

C.p=0;

D.p=";

27.有以下程序:

#include

main()

{int a[]={10,20,30,40},*p=a,j;

for(i=0;i<=3;i++){a[i]=*P;p++;}

printf("oAd\n",a[2]);

}

程序运行后的输出结果是( )。

A.30

B.40

C.10

D.20

28.有以下程序:

#include

#define N 3

void fun(int a[][N],int b[])

{ int i,j;

for(i=0;i

for(j=i;j

}

main()

{int x[N][N]={1,2,3,4,5,6,7,8,9},y[N],i;

fun(x,y);

for(i=0;i

}

程序运行后的输出结果是(,)。

A.2,4,8,

B.3,6,9,

C.3,5,7,

D.1,3,5,

29.有以下程序(strcpy为字符串复制函数,strcat为字符串连接函数):

#include

#include

main()

{char a[10]="abc",b[10]="012",c[10]="xyz";

strcpy(a+1,b+2);

puts(strcat(a,c+1));

}

程序运行后的输出结果是( )。

A.al2xyz

B.12yz

C.a2yz

D.bc2yz

30.以下选项中,合法的是( )。

A.char str3[]={’d’,’e’,’b’,’u’,’g’,’\0’};

B.char str4;str4="hello world";

C.char name[10];name="china";

D.char strl[5]="pass",str2[6];str2=strl;

31.有以下程序:

#include

main()

{ char*s="[2]34";int k=0,a=0;

whil(s[k+1]!=’\o’)

{ k++;

if(k%2=o){a=a+(s[k]-’0’+1);continue; }

a=a+(s[k]-’0’);

printf("k=%d a=%d\n",k,a);

}

程序运行后的输出结果是( )。

A.k=6 a=11

B.k=3 a=14

C.k=4 a=12

D.k=5 a=15

32.有以下程序:

#include

main()

{char a[5][10]={"one","tw0","three","four","five"};

int i,j;

char t: 、

for(i=0;i<4;i++)

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

if(a[i][O]>a[j][0])

{t=a[i][O];a[i][O]=a[j][O];a[j][O]=t;)

puts(a[1]);

}

程序运行后的输出结果是( )。

A.fwo

B.fix

C.two

D.owo

33.有以下程序:

#include

int a=1,b=2:

void funl(int a,int b)

{printf( "%d%d",a,b); }

void fun2()

{ a=3;b=4; }

main()

{ funl(5,6);fun2();

printf("%d%d\n",a,b);

}

程序运行后的"输出结果是( )。

A.1 2 5 6

B.5 6 3 4

C.5 6 1 2

D.3 4 5 6

34.有以下程序:

#include

void func(int n)

{ static int num=1);

num=num+n;printf("%d",num);

}

main()

{funo(3);func(4);printf("n"); }

程序运行后的输出结果是( )。

A.4 8

B.3 4

C.3 5

D.4 5

35.有以下程序:

#include

#include

void fun(int*pl,int*p2,int*s)

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。

推荐词条