C语言笔试题100道
b)25
c)24
d)30
33) 设x,y,z,t均为int型变量,则执行以下语句后,t的值为()。
x=y=z=1;
t=++x||--y&&++z;(选择一项)
a)不定值
b)2
c)1
d)0
34) void fun(int *x, int *y) { *x=3;*y=4; }
void main()
{
int x=1,y=2;
printf("%d %d ",x, y);
fun(&y,&x);
printf("%d %d",x, y);
}
上面的C程序段的输出结果是()。(选择一项)
a)2 1 4 3
b)1 2 1 2
c)1 2 4 3
d)2 1 1 2
35) 分析下面的C语言程序:
#include
struct stu
{
int num;
char name[10];
int age;
};
void main()
{
struct stu students[3]={{9801,”Zhang”,20},{9802,”Wang”,19},{9803,”Zhao”,18} };
printf(“%s\n”,(*(students+2)).name);
}
输出结果是()。(选择一项)
a)Zhang
b)Zhao
c)Wang
d)18
36) 阅读下面的C语言代码,输出结果是()。
int x, y = 1, z=0;
if ( z < 0 )
x = 3;
else if ( y == 0 )
x = 5;
else
x = 7;
printf("%d, %d", x, y);(选择一项)
a)7, 0
b)7, 1
c)3, 3
d)以上都不正确
37) 要将20赋值到数组Num的第三个元素,正确的方法是()。(选择一项)
a)Num[3]=20
b)Num[2]=20
c)Num[4]=20
d)[3] Num=20
38) 在C语言中,已知字母A的ASCII码是65,则执行语句:char ch='A'+3; 后ch的值为( )。(选择一项)
a)不能确定
b)68
c)C
d)D
39) 在C语言中,以下所列的各函数首部中,正确的是( )。(选择一项)
a)void play(var :Integer,var b:Integer)
b)void play(int a,b)
c)void play(int a,int b)
d)Sub play(a as integer,b as integer)
40) C语言中,可以通过指针访问一个变量,表示指针的运算符是()。(选择一项)
a)&
b)*
c)^
d)%
e)@
41) 下面的C程序段执行完后,x的值为( )。
int x=3, y=2;
x*=x+y;(选择一项)
a)2
b)10
c)15
d)3
42) 在C语言中,能正确表示a和b同时为正或同时为负的逻辑表达式是()。(选择一项)
a)(a>=0‖b>=0)&&(a<0‖b<0)
b)(a>=0&&b>=0)&&(a<0&&b<0)
c)(a+b>0)&&(a+b<=0)
d)a*b>0
43) 下面的C语言代码段的输出结果是()。(选择一项)
int j;
for(j=1; j<10; j+=2)
printf("%d ",j);
a)1 2 3 4 5 6 7 8 9
b)2 4 6 8
c)1 3 5 7 9
d)1 2 4 6 8
44) 用来将两个字符串合并为一个字符串的函数是()。(选择一项)
a)strcat()
b)strcpy()
c)strlen()
45) 在C语言中,表达式:10!=9 的值是()。(选择一项)
a)true
b)非零值
c)0
d)1
46) 分析下面的C代码段:
char str1[15] = "Sea View";
char str2[15] = "Sea Breeze";
strcpy(str1,str2);
printf("%s\n",str1);
则输出结果是()。(选择一项)
a)Sea View
b)Sea Breeze
c)Sea View Sea Breeze
d)Sea Breeze Sea View
47) 在C语言中,下列正确的字符型常量是()。(选择一项)
a)“f ”
b)‘9’
c) #
d)365
48) 下面说法正确的是()。(选择三项)
1)C语言中for 循环可以重复执行操作
2)do 操作至少要执行一次
3)exit()函数会立即使程序结束
a)1)和2)都是错误的
b)1)是正确的
c)2)是正确的
d)3)是正确的
49) 在C语言中,以下不会出现死循环的语句是()。(选择一项)
a) int x=0;
do{x++;}while(x=1);
b) for(k=10; ; k--);
c)for(y=0, x=1; x>++y; x=k++) k=x;
d)while(1) {x++;}
50) 分析下面的C语言程序:
void main()
{
int a,b,c=246;
a=c/100%9;
b=(-1)&&(-1);
printf(“%d,%d\n”,a,b);
}
输出结果是()。(选择一项)
a)2,1