C语言试题

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

一、Select one answer from the four answers:(

for each question, a total of 30 points)

1.Which of the following expressiong is the equivalent to k=n++? ( ).

A) k=n,n=n+1 B)n=n+1,k=n C)k=++n D)k+=n+1

2.What will be the printed output of the following program? ( ).

main( )

{ int x=10,y=10;

printf("%d %d\n",x--,--y);

}

A)10 10 B) 9 9 C) 9 10 D) 10 9

3.Choose the correct output that following program produces. ( ).

main()

{ int x;

x=-3+4*5-6; printf("%d",x);

x= 3+4%5-6; printf("%d",x);

x=-3*4%6/5; printf("%d",x);

x=(7+6)%5/2; printf("%d",x);

}

A) 11 1 0 1 B) 11 -3 2 1 C) 12 -3 2 1 D)11 1 2 1

4. The printed output of the following program is ( ).

#include

main()

{ int y=10;

do{y--;}while(--y);

printf("%d\n",y--);

}

A) -1 B) 1 C) 8 D) 0

5. The printed output of the following program is ( ).

#include

main()

{ int i,b,k=0;

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

{ b=i%2;

while(b-->=0) k++;

}

printf("%d, %d",k,b);

}

A) 3, -1 B) 8, -1 C) 3, 0 D) 8, -2

6.The correct expression to determain whether ch is a capital letter is( ).

A) 'A'<=ch<='Z' B) (ch>='A')&&(ch<='Z')

C) (ch>='A')&(ch<='Z') D) (ch>='A')AND(ch<='Z')

7.Given a program as follows,the output will be( ) if data ADescriptor

is keyed in when the program is running.

#include

main()

{ char c;

int v0=0,v1=0,v2=0;

do{

switch( c=getchar())

{ case 'a': case 'A':

case 'e': case 'E':

case 'i': case 'I':

case 'o': case 'O':

case 'u': case 'U': v1+=1;

default: v0+=1; v2+=1;

}

}while(c!='\n');

printf("v0=%d,v1=%d,v2=%d",v0,v1,v2);

}

A)v0=7,v1=4,v2=7; B)v0=8,v1=4,v2=8;

C)v0=11,v1=4,v2=11; D)v0=12,v1=4,v2=12;

8.Given the declarations

int a[][3]={1,2,3,4,5,6,7,8,9}

the size of the first dimension of array a is ().

A) 2 B) 3 C) 4 D) 5

9.The return type of the following program is( ).

seed(double y)

{

double z;

z=x/2+5;

return y;

}

A)int B)uncertain C)void D)float

10. The following program will print out( ).

main()

{

int m=5;

if(m++>5) printf("%d\n",m);

else printf("%d\n",m--);

}

A) 4 B) 5 C) 6 D) 7

11. Perform the following program. The printed output will be ( )if 3 is keyed in.

#include

main()

{

int k;

scanf("%d",&k);

switch(k)

{

case 1:printf("%d\n",k++);

case 2:printf("%d\n",k++);

case 3:printf("%d\n",k++);

相关文档
最新文档