红灯停绿灯行c语言编程,C语言 实验三C语 实验三.doc

C语言 实验三C语 实验三

1221410042 张锦华

18.3 最简单的C程序设计

-----实验报告

(1)①源程序

#include

void main()

{int a,b;

float d,e;

char c1,c2;

double f,g;

long m,n;

unsigned int p,q;

a=61;b=62;

c1='a';c2='b';

d=3.56;e=-6.87;

f=3157.890121;g=0.123456789;

m=50000;n=-60000;

p=32768;q=40000;

printf("a=%d,b=%d\nc1=%c,c2=%c\nd=%6.2f,e=%6.2f\n",a,b,c1,c2,d,e);

printf("f=%15.6f,g=%15.12f\nm=%ld,n=%ld\np=%u,q=%u\n",f,g,m,n,p,q);

}

编译结果:

--------------------Configuration: 18.31 - Win32 Debug--------------------

Compiling...

18.31.c

C:\Documents and Settings\Administrator\物理学院张锦华C语言\18.31.c(11) : warning C4305: '=' : truncation from 'const double ' to 'float '

C:\Documents and Settings\Administrator\物理学院张锦华C语言\18.31.c(11) : warning C4305: '=' : truncation from 'const double ' to 'float '

18.31.obj - 0 error(s), 0 warning(s)

②运行结果:

③修改后源程序

#include

void main()

{int a,b;

float d,e;

char c1,c2;

double f,g;

long m,n;

unsigned int p,q;

a=61;b=62;

c1=a;c2=b;

d=3.56;e=-6.87;

f=3157.890121;g=0.123456789;

d=f;e=g;

p=a=m=50000;q=b=n=-60000;

printf("a=%d,b=%d\nc1=%c,c2=%c\nd=%6.2f,e=%6.2f\n",a,b,c1,c2,d,e);

printf("f=%15.6f,g=%15.12f\nm=%ld,n=%ld\np=%u,q=%u\n",f,g,m,n,p,q);

}

编译结果:

--------------------Configuration: 18.31 - Win32 Debug--------------------

Compiling...

18.31.c

C:\Documents and Settings\Administrator\物理学院张锦华C语言\18.31.c(11) : warning C4305: '=' : truncation from 'const double ' to 'float '

C:\Documents and Settings\Administrator\物理学院张锦华C语言\18.31.c(11) : warning C4305: '=' : truncation from 'const double ' to 'float '

C:\Documents and Settings\Administrator\物理学院张锦华C语言\18.31.c(13) : warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data

C:\Documents and Settings\Administrator\物理学院张锦华C语言\18.31.c(13) : warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data

18.31.obj - 0 error(s), 0 warning(s)

修改后运行结果:

④修改后源程序

#include

void main()

{int a,b;

float d,e;

char c1,c2;

double f,g;

long m,n;

unsigned int p,q;

scanf("%d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值