- 5
- 0
- 约1.07万字
- 约 15页
- 2017-05-12 发布于河南
- 举报
C语言试卷(2000-1-5)
《C 语言模拟考题》
一、选择题
C语言中, char、 int、 float和double类型的数据分别占用【1】个字节。
【1】 A) 2、2、3、4 B)1、2、4、6 C) 1、2、4、8
2、若执行printf(%d\n, strlen(a\n\\\x41))语句其输出结果是 【2】 。
【2】 A) 8 B) 7 C) 6 D) 4
3、若int a, b, c; 则表达式(a=2, b=5, b++, a+b)的值是 【3】 。
【3】 A) 7 B) 8 C) 6 D) 2
4、以下正确的叙述是 【4】 。
【4】 A) 在C语言中,main函数必须位于文件的开头
B) C语言每行中只能写一条语句
C) C语言本身没有输入、输出语句
D) 对一个C语言进行编译预处理时,可检查宏定义的语法错误
5、若执行以下程序段:
int a=1, b=2, m=2, n=2;
(m=ab)++n;
则n的值是 【5】 。
【5】 A) 1 B) 2 C) 3 D) 4
注:类似的如以下题:
int a=1, b=1, c=0;
if (++a || ++b) c=a+b;
printf(a=%d b=%d c=%d\n, a,b,c);
6、已知各变量的类型如下:
int i=8, a, b;
double x=1.42, y=5.2;
则以下符合C语言语法的表达式是 【6】 。
【6】 A) a+=a-=(b=4)*(a=3) B) a=a*3=2
C) x%(-3) D) y=float(i)
7、以下程序的运行结果是 【7】 。
#include stdio.h
main()
{ int m=5;
if(m++5) printf(%d\n, m);
else printf(%d\n, m++);
}
【7】 A) 7 B) 6 C) 5 D) 4
8、以下程序的运行结果是 【8】 。
#include stdio.h
main()
{
char c=y;
if(c=ac=u) c+=5;
else if(c=vc=z) c-=21;
putchar(c);
}
【8】 A) y B) d C) y D) d
9、若定义int i; 则以下循环语句的循环执行次数是 【9】 。
for(i=2; i==0;) printf(%d, i--);
【9】 A) 无限次 B) 0次 C) 1次 D) 2次
10、以下程序的运行结果是 【10】 。
#include stdio.h
main()
{
int a[4][3]={ 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12};
int *p, j;
p=a[0];
printf(%2d,%2d,%2d,%2d\n, *p, *(*(a+3)+2), p[2], *(p+7));
}
【10】 A) 4, 4, 9, 8 B) 程序出错 C) 1, 10, 12, 8 D) 1, 9, 2, 7
/************************/
11、以下程序的输出结果是 【11】 。
#include stdio.h
main()
{
int i=0;
while(1)
{
printf(*);
i++;
if(i3) break;
}
printf(\n);
}
【11】 A) * B) *** C) ** D) ****
12、若定义a[][2]={1,2,3,4,5,6,7}; 则a数组中行的大小是 【12】 。
【12】 A) 2 B) 3 C) 4 D) 无确定值
13、要使以下程序中t的输出结果是4,则输入a和b应满足的条件是 【13】 。
#include stdio.h
main()
{
int s, t, a, b;
scanf(%d%d, a, b);
s=t=1;
if(a0) s+=1;
if(ab) t=s+t;
else
if(a==b) t=5;
else t=2*s;
printf(%d\n, t);
}
【13】 A) a0并且ab B) a0并且ab C) a0并且ab D) a0并且ab
14、以下程序的运行结果是 【14】 。
#include stdio.h
void f(int b[])
{
int i=0;
while(b[i]=10)
{
b[i]+=2;
i++;
}
}
main()
{
int i, a[]={ 1, 5,10, 9,13, 7};
f(a+1);
for(i=0; i6; i++)
printf(%d ,
原创力文档

文档评论(0)