C语言基础复习题.docx
- 文档编号:29964612
- 上传时间:2023-08-03
- 格式:DOCX
- 页数:30
- 大小:31.12KB
C语言基础复习题.docx
《C语言基础复习题.docx》由会员分享,可在线阅读,更多相关《C语言基础复习题.docx(30页珍藏版)》请在冰豆网上搜索。
C语言基础复习题
C语言复习题
(1)
一、一、 选择题:
下列各题A)、B)、C)、D)四个选项中只有一个是正确的,请将正确的选项涂写在答案纸上。
答在试卷上不得分。
(1)C语言规定:
在一个源程序中,main函数的位置。
A)必须在最后B)必须在系统调用的库函数的后面。
C)必须在最开始。
。
D)可以任意
(2)C语言中的标识符只能由字母、数字和下划线三种字符组成,且第一个字符。
A)必须为字母或下划线。
。
B)必须为下划线。
C)必须为字母D)可以是字母、数字和下划线中的任一种字符。
(3)下面四个选项中,均是正确的八进制数或十六进制数的选项是。
A)-100x8f-011B)010-0x110xf1
C)0abc-0170xcD)0a12-0x123-0xa
(4)C语言中int型数据在内存中占两个字节,则unsegnedint取值范围是。
A)0~65535B)0~32767
C)-32767~32768D)-32768~327687
(5)若有定义:
inta=7;floax=2.5,y=4.7;
则表达式x+a%3*(int)(x+y)%2/4的值是。
A)2.750000B)0.00000C)3.500000D)2.500000
(6)已知ch是字符型变量,下面不正确的赋值语句是。
A)ch=5+9;B)ch='a+b';C)ch='\0';D)ch='7'+'6';
(7)设x,y和z是int型变量,且x=3,y=4,z=5则下面表达式中值为0的
是。
A)!
((x z||1)B)'x'&&'y'C)x||y+z&&y-zD)x<=y (8)设有程序段 intk=10; while(k=0)k=k-1; 以下描述正确的是。 A)循环体语句一次也不执行。 B)循环是无限循环。 C)while循环语句执行十次。 D)循环体语句执行一次。 (9)以下C程序正确的运行结果是。 main() {longy=23456; printf("y=%3x\n",y); printf("y=%8x\n",y); printf("y=%#8x\n",y); } A)y=5ba0B)y=5ba0C)y=5ba0D)y=5ba0 y=5ba0y=5ba0y=bba0y=5ba0 y=0x5ba0y=0x5ba0y=0x5ba0y=####5ba0 (10)当a=1,b=3,c=5d=4时,则执行完下面一段程序后,x的值是。 if(a if(c else if(a if(b elsex=3; elsex=6; elsex=7; A)1B)3C)2D)6 (11)下面程序的运行结果是。 #include"stdio.h" main() {inta=1,b=10 do {b-=a;a++;} while(b--<0); printf("a=%d,b=%d\n),a,b); A)a=3,b=11B)a=4,b=9 C)a=1,b=-1D)a=2,b=8 (12)以下for循环的执行次数是。 for(x=0,y=0;(y=123)&&(x<4);x++); A)无限次。 B)4次。 C)0次。 D)3次。 (13)以下是死循环的程序段的是。 A)for(i=1;;)B)i=32767 {if(++i%2==0)continue;do{if(i<0)break;}while(++i) if(++i%3==0)break;} C)for(i=1;;)D)i=1 if(++i<10)continue;while(i--); (14)若有说明: inta[10];则对a数组元素的正确引用是。 A)a[10]B)a[10-10]C)a(5)D)a[3.5] (15)根据定义和数据的输入方式,输入语句的正确形式为。 已有定义: floatf1,f2;数据输入方式: 4.25 3.5 A)scanf("%f%f",&f1,&f2);B)scanf("%f,%f",&f1,&f2); C)scanf("%3.2f%2.1f",&f1,&f2);D)scanf("%2.1f%3.2f",&f1,&f2); (16)已知ch是字符型变量,下面正确的赋值语句是。 A)ch='123';B)ch='\08';C)ch='\xff';D)ch="\"; (17)以下if语句语法正确的是。 A)if(x>0)B)if(x>0)printf("%f",-x) {x=x+y;printf("%f",x);}elseprintf("%f",-x); elseprintf("%f",-x); C)if(x>0)D)if(x>0) {x=x+y;printf("%f",x);};{x=x+y;peintf("%f",x)} elseprintf("%f",-x);elseprintf("%f",-x); (18)若W=1,X=2,Y=3,Z=4则条件式: W W: Y Y: Z的值是。 A)1B)3C)4D)2 (19)以下程序段。 x=-1; do{x=x*x;} while(! x); A)是死循环B)循环执行一次 C)循环执行二次D)有语法错误 (20)逻辑运算符两侧运算对象的数据类型。 A)只能是0或1B)可以是任何类型的数据 C)只能是整型或字符型数据D)只能是0或非0正数 (21)下面程序中有错误的行是。 (前面数字表示行号) 1、1、 main()5、scanf("%d",&a); 2、2、 {6、for(i=1;i<3;i++)a[0]=a[0]+a[i], 3、3、 inta[3]={1};7、printf("a[0]=%d\n",a[0]); 4、4、 inti;8、} A)3B)6C)5D)7 (22)下面的程序段。 for(t=1;t<=100,t++) {scanf("%d",&x); if(x<0)continue; printf("%3d",t); } A)当x<0时整个循环结束B)当x>=0时什么也不输出 C)printf函数永远也不执行D)最多允许输出100个非负整数 (23)以下对一维整型数组a的正确说明是。 A)inta(10)B)intn=10;a[n]; C)intn;D)#defineSIZE10 scanf("%d",&n);inta[SIZE]; inta[n]; (24)下面程序的运行结果是。 a=1;b=2;c=2; while(a printf("%d,%d,%d",a,b,c); A)1,2,0B)2,1,0C)1,2,1D)2,1,1 (25)若有说明: inta[3][4];则对数组元素的非法引用是。 A)a[0][2*1]B)a[0][4]C)a[4-2][0]D)a[1][3] (26)对以下说明的正确理解是。 inta[10]={6,7,8,9,10} A)将5个初值依此赋给a[1]至a[5]B)将5个初值依此赋给a[0]至a[4] C)将5个初值依此赋给a[6]至a[10]D)因长度与初值个数不同,故语句错误 (27)若二维数组a有m列,则在a[i][j]前的元素个数为 A)i*m+jB)j*m+iC)i*m+j-1D)i*m+j+1 (28)以下程序段运行的结果是。 charc[5]={'a','b','\0','c','\0'}; printf("%s",c); A)'a''b'B)abcC)abcD)ab (29)以下正确的函数定义形式是。 A)doublefun(intx,inty)B)doublefun(intx;inty) C)doublefun(intx,inty);D)doublefun(intx,inty); (30)以下不正确的说法是。 A)实参可以是常量、变量或表达式。 B)形参应与其对应的实参类型一致。 C)实参可以为任意类型。 D)形参可以是常量、变量或表达式。 (31)有两个字符数组a,b,则以下正确的输入格式是。 A)scanf("%s%s",&a,&b)B)gets(a,b) C)scanf("%s%s",a,b)D)gets("a");gets("b") (32)以下程序正确的运行结果是。 main() {inta=2,i; for(i=0;i<3;i++)printf("%4d",f(a)); } f(inta) {intb=0;staticintc=3; b++;c++; return(a+b+c);} A)777B)71013C)789D)7911 (33)#define能做简单的替代,用宏替代计算多项式4*x*x+3*x+2之值的函数f,正确的宏定义是。 A)#definef(x)4*x*x+3*x+2B)#definef4*x*x+3*x+2 C)#definef(a)(4*a*a+3*a+2)D)#define(4*a*a+3*a+2)f(a) (34)当运行以下程序时,从键盘输入: ab c def ( #include"stdio.h" #defineN6 main() {charc(N); inti=0; for(;i for(i=0;i } A)abcdefB)aC)bD)ab bcc cdd d e f (35)请读程序: #defineAD(x)x+x main() {intm=1,n=2,k=3; intsum=AD(m+n)*k; printf("sum=%d",sum);} 上面程序的运行结果是。 A)sum=9B)sum=10C)sum=12D)sum=18 (36)对下面程序段正确的判断是: ___________ #defineA3 #defineB(a)((A+1)*a) x=3*(A+B(7)); A)A) 程序错误,不许嵌套宏定义。 B)x=21 C)x=93D)程序错误,宏定义不许有参数。 (37)执行以下程序后,a,b的值为&lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 基础 复习题