编译预处理C语言实验报告,c语言编译预处理实验报告.docx

C 语言 编译预处理 实验报告

实验名称:编译预处理

一 . 实验目的

(1) 掌握文件包含、宏定义、条件编译、 assert 宏的使用。 (2)练习带参数的宏定义、条件编译的使用。

( 3)练习 assert 宏的使用。 (4)使用集成开发环境中的调试功能:单步执行,设置断点,观察变量。

二、实验内容

源程序改错:

源程序: #include #define SUM a+b #define DIF a-b #define SWAP(a,b) a=b, b=a

int main()

{

int b, t;

printf("Input two integers a,b:"); scanf("%d, %d", &a, &b);

square bprintf("\nSUM=%d\n the difference between square of a and is:%d",SUM,SUM*DIF);

square b

SWAP(a,b);

Printf("\nNow a=%d,b=%d\n", a, b); return 0;

}.

源程序修改替换

源程序 : void main(void)

{

int a, b, c;

float d, e;

printf("Enter three integers:"); scanf("%d, %d, %d", &a, &b, &c);

printf("\nthe maximum of them is %d\n", max(a,b,c)); printf("Enter two floating point numbers:");

scanf("%f, %f", &d, &e); printf("\nthe sum of them is%f\n",sum(d,e));

return 0;

int max(int x, int y, int z)

{

int t; if (x > y) t = x;

else

t = y;

if (t < z)

t = z; return t;

}

跟踪调试程序

程序代码:

#define R

int main(void)

{

float r, s; int s_integer = 0; printf("input a number:");

scanf("%f", &r);

#ifdef R s = 3.14159 * r * r; printf("area of round is:%f\n", s); s_integer = integer_fraction(s); printf("the integer fraction of area is %d\n", s_integer); assert((s-s_integer) < 1.0);

#endif

return 0;

}

int integer_fraction(float x)

{

int i = x; return i; }

程序设计

三、实验步骤及结果

步骤:1.编写源程序

对源程序进行编译,修改错误,运行修改后的程序

3?发现结果有误,进行调试。

C: \Us-e r a \ zucke B.C:\Users\zucke _

C: \Us-e r a \ zucke B.

C:\Users\zucke _ .. -10

C: \Users\zucke10

C: \Userjs\zueke. - -10

C:\xuak9.?■12

C:??■ 13

C■匚 \Us&rs Vxucrks. . , g

C: \口三亡匸三、蛊口uJce-?-15

In function Tsnai!!ii :

errori " ar undeclared first 口勻皀 ±el tfciis function)

eezqez (Each undeclared idenier ±s reported only once error s f or each func&ioxi i€ appeals ia.)

^4 rniEg r l#f b-hdnd open nd cjf oojzuti# exprejs xgh h?> no *£fecfa rarni^g:t d#fl^rdof functicj: pPriistfr

irarning; :yjnj#來iritr

errorz ez^eexed Ldeni;if±er or ,r (" before 1 . 1 token

= Build finished: 4 errors r 3 warnings =

第一次修改后的程序和结果:

#i nclude

#defi ne SUM a+b

#defi ne D

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip实验一 源程序的预处理及词法分析程序设计等.zip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值