预处理习题

上传人:luoxia****01802 文档编号:70364442 上传时间:2019-01-16 格式:PPT 页数:35 大小:140KB
返回 下载 相关 举报
预处理习题_第1页
第1页 / 共35页
预处理习题_第2页
第2页 / 共35页
预处理习题_第3页
第3页 / 共35页
预处理习题_第4页
第4页 / 共35页
预处理习题_第5页
第5页 / 共35页
点击查看更多>>
资源描述

《预处理习题》由会员分享,可在线阅读,更多相关《预处理习题(35页珍藏版)》请在金锄头文库上搜索。

1、81 1、C语言编译系统对宏命令是 。 A、在程序运行时进行代换处理的 B、在程序连接时进行处理的 C、和源程序中其它C语句同时进行编译的 D、在对源程序中其他成分正式编译之前进行处理的,2、C语言的预处理命令 C语言语句。 A、是 B、不是 3、以下描述正确的是 。 A、每个C程序必须在开头用预处理命令: include B、预处理命令必须位于C程序的首部 C、在C语言中预处理命令都以“”开头 D、C语言的预处理命令只能实现宏定义和条件编 译的功能,4、在宏定义define PI 3.14159中,用宏名PI代替一个 。 A、单精度数 B、双精度数 C、常量 D、字符串 5、下列正确的预编译

2、命令是 。 A、define PI 3.14159 B、#define P(a,b) strcpy(a,b) C、#define stdio.h D、#define PI 3.14159,6、设有宏定义“#define AREA(a,b)a*b”,则正确的“宏调用”是 。 A、s=AREA(r*r) B、s=AREA(x*y) C、s=AREA D、s=c*AREA(x=3.5),(y+4.1) 7、设有以下宏定义,则执行语句“z=2*(N+Y(5+1);” 后,z的值是 。 #define N 3 #define Y(n) (N+1)*n) A、出错 B、42 C、48 D、54,8、设有以

3、下宏定义,当int x,m5,n1时,执行语句“IFABC(m+n,m,x);”后,x的值是 。 #define IFABC(a,b,c) c=ab?a:b A、5 B、6 C、11 D、出错,9、有以下程序: #include #define f(x) x*x main() int i; i=f(4+4)/f(2+2); printf(“%dn“,i); 执行后输出结果是 。 A、28 B、22 C、16 D、4,10、以下程序的输出结果是 。 #include #define f(x) x*x main() int a=6,b=2,c; c=f(a)/f(b); printf(“%dn“,

4、c); A、9 B、6 C、36 D、18,11、以下程序的输出结果是 。 #include #define MA(x) x*(x-1) main() int a=1,b=2; printf(“%dn“,MA(1+a+b); A、6 B、8 C、10 D、12,12、有如下程序: #include #define N 2 #define M N+1 #define NUM 2*M+1 main() int i; for(i=1;i=NUM;i+) printf(“%dn“,i); 该程序中for循环执行的次数是 。 A、5 B、6 C、7 D、8,13、以下程序的输出结果是 。 #includ

5、e #define M(x,y,z) x*y+z main() int a=1,b=2,c=3; printf(“%dn“,M(a+b,b+c,c+a); A、19 B、17 C、15 D、12,14、以下程序的输出结果是 。 #include #define MIN(x,y) (x)(y)?(x):(y) main() int i,j,k; i=10;j=15; k=10*MIN(i,j); printf(“%dn“,k); A、15 B、100 C、10 D、150,15、以下程序的输出结果是 。 #include #define PT 5.5 #define S(x) PT*x*x ma

6、in() int a=1,b=2; printf(“%4.1fn“,S(a+b); A、49.5 B、9.5 C、22.0 D、45.0,16、以下程序的输出结果是 。 #include #define SUB(X,Y) (X)*Y main() int a=3,b=4; printf(“%d“,SUB(a+,b+); A、12 B、15 C、16 D、20,17、执行下面的程序后,a的值是 。 #include #define SQR(X) X*X main() int a=10,k=2,m=1; a/=SQR(k+m)/SQR(k+m); printf(“%dn“,a); A、10 B、1

7、 C、9 D、0,18、以下程序的输出结果是 。 #include #define JH(x,y) x=xy;y=xy;x=xy; main() int a=3,b=5,c=7; JH(a,b); JH(b,c); JH(a,c); printf(“a=%d,b=%d,c=%dn“,a,b,c); ,19、以下程序的输出结果是 。 #include #define A 3 #define B(a) (A+1)*a) main() int x; x=3*(A+B(7); printf(“X=%dn“,x); ,20、以下程序的输出结果是 。 #include #define POWER(x) (

8、x)*(x) main() int i=1; while (i=4) printf(“%d“,POWER(i+); printf(“n“); ,21、以下程序的输出结果是 。 #include #define MAX(x,y) (x)(y)?(x):(y) main() int a=5,b=2,c=3,d=3,t; t=MAX(a+b,c+d)*10; printf(“%dn“,t); ,22、以下程序的输出结果是 。 #include #define M 5 #define N M*3+4 #define MN N*M #include main() printf(“%d,%dn“,2*MN

9、,MN/2); ,23、以下程序的输出结果是 。 #include #define EXCH(a,b) int t;t=a;a=b;b=t; main() int x=5,y=9; EXCH(x,y); printf(“x=%d,y=%dn“,x,y); ,24、设有如下宏定义: #define MYSWAP(z,x,y) int z=x;x=y;y=z; 以下程序段通过宏调用实现变量a、b内容交换,请填空。 float a=5,b=16,c; MYSWAP( ,a,b);,25、以下程序的输出结果是 。 #include #define MCRA(m) 2*m #define MCRB(n,

10、m) 2*MCRA(n)+m main() int i=2,j=3; printf(“%dn“,MCRB(j,MCRA(i); ,26、以下程序的输出结果是 。 #include #define A 3 #define B(a) (A+1)*a) main() int x; x=3*(A+B(7); printf(“x=%dn“,x); ,27、分析以下程序的输出结果。 #include #define PR(ar) printf(“%d“,ar) main() int j,a=1,3,5,7,9,11,13,15,*p=a+5; for(j=3;j;j-) switch(j) case 1:

11、 case 2:PR(*p+);break; case 3:PR(*(-p); ,28、分析以下程序的执行结果。 #include #define PR(x,y,z) printf(“x=%d y=%d z=%dn“,x,y,z) main() int x,y,z; x=y=z=2;+x|+y ,822 1、以下程序的输出结果是 。 #include void main() #if defined(NULL) printf(“NULL=%dn“,NULL); #else printf(“NULL未定义!n“); #endif ,2、以下程序的输出结果是 。 #include #define A

12、BCD void main() #if defined(ABCD) printf(“ABCDn“); #else printf(“ABCD未定义!n“); #endif ,3、说明以下程序的功能。 #include void main() float r,s; printf(“输入半径:“); scanf(“%f“, ,832 1、以下 不是C语言所提供的预处理命令。 A、宏定义 B、文件包含 C、条件编译 D、字符预处理 2、对文件包含处理,在编译时 。 A、把用include命令指定的文件与本文件用link命令进行联接 B、把用include命令指定的文件与本文件进行宏替换 C、把用inc

13、lude命令指定的文件与本文件用project命令进行联接 D、把用include命令指定的文件与本文件作为同一个源文件进行编译,3、以下说法正确的是 。 A、用include包含的头文件后缀不可以是“.a” B、可以使用undef命令来终止宏定义的作用域 C、在进行宏定义时,宏定义不能层层替换 D、对程序中用双引号括起来来的字符串内的字符,与宏名相同的要进行替换,4、程序中头文件type1.h的内容是: #define N 5 #define M1 N*3 程序如下: #include “type1.h“ #define M2 N*2 void main() int i; i=M1+M2;

14、printf(“%dn“,i); 程序的运行结果是 。,5、以下程序的功能是 。 a.c文件: #include #include “type1.h“ void main() func(); type1.c文件: void func() char c; if(c=getchar()!=n) func(); putchar(c); ,842 1、以下程序的运行结果是 。 #include void main() struct st unsigned a:10; unsigned b:12; unsigned c:2; x; printf(“%dn“,sizeof(x); ,2、以下程序的运行结果是 。 #include void main() struct st unsigned a:20; x; printf(“%dn“,sizeof(x); ,3、以下程序的输出结果是 。 #include void main() struct st unsigned short a:10; unsigned short b:6; bit,*pbit; bit.a=100; bit.b=20; printf(“%d,%d,“,bit.a,bit.b); pbit= ,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 调研报告

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号