您的位置:首页 > 编程语言 > C语言/C++

C语言-数据类型在LR中的应用

2016-09-07 10:49 176 查看
计算矩形和圆形面积

#define PI 3.1415

Action()

{
int Area;//定义矩形面积
int length=10,width=10;//定义一个矩形的长和宽

float r=4.5,s;//定义两个不同半径的圆s和s1
double r1=34.81,s1;

char x='z';//定义单独字符x

Area=length*width;//计算矩形面积

s=PI*r*r;//计算不同半径圆的面积
s1=PI*r1*r1;

lr_output_message("面积为:%d(十进制)",Area);//输出矩形面积
lr_output_message("面积为:%o(八进制)",Area);
lr_output_message("面积为:%x(十六进制)",Area);

    lr_output_message("\n");//换行

lr_output_message("半径为%.f(四舍五入取整数)的面积为:%f",r,s);//输出圆形面积
lr_output_message("半径为%.f的面积为:%.3f(保留3位小数)",r1,s1);
lr_output_message("/n");

lr_output_message("char常量字符表示为:%c",x);
lr_output_message("char常量字符用整数:%d",x);
lr_output_message("/n");

lr_output_message("Area占用字节大小为:%d",sizeof(Area));

return 0;
}

运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息