c语言 ld long double,重试C语言之C语言数据类型

通过本篇文章,我们的学习目的如下:

1、了解数据类型的基本分类

2、 熟练掌握基本数据类型

C 语言数据类型可以分为以下几种:

0818b9ca8b590ca3270a3433284dd417.png

数组类型和结构类型,我们统称为聚合类型,函数类型指的是函数的返回值类型。在今天的这篇文章中,我们将重点讲解基本类型,其他的类型,我们会放在以后的章节在做详细的讲解。

整数类型:下表列出标准整数类型的存储大小和值范围

0818b9ca8b590ca3270a3433284dd417.png

C语言程序示例(整数类型存储大小):

#include

#include

int main()

{

printf("Storage size for int : %d \n", sizeof(char));

printf("Storage size for int : %d \n", sizeof(unsigned char));

printf("Storage size for int : %d \n", sizeof(signed char));

printf("Storage size for int : %d \n", sizeof(int));

printf("Storage size for int : %d \n", sizeof(unsigned int));

printf("Storage size for int : %d \n", sizeof(short));

printf("Storage size for int : %d \n", sizeof(unsigned short));

printf("Storage size for int : %d \n", sizeof(long));

printf("Storage size for int : %d \n", sizeof(unsigned long));

return 0;

}

相关C语言技术点补充:

为了得到某个类型或某个变量在特定平台上的准确大小,您可以使用

sizeof

运算符。表达式

sizeof(type)

得到对象或类型的存储字节大小。

浮点类型:下表列出标准浮点类型的存储大小、值范围和精度

0818b9ca8b590ca3270a3433284dd417.png

C语言程序示例(浮点类型)

#include

#include

int main()

{

printf("Storage size for float : %d \n", sizeof(float));

printf("Minimum float positive value: %E\n", FLT_MIN );

printf("Maximum float positive value: %E\n", FLT_MAX );

printf("Precision value: %d\n", FLT_DIG );

printf("Storage size for double : %d \n", sizeof(double));

printf("Minimum double positive value: %E\n", DBL_MIN );

printf("Maximum double positive value: %E\n", DBL_MAX );

printf("Precision value: %d\n", DBL_DIG );

printf("Storage size for long double : %d \n", sizeof(long double));

printf("Minimum long double positive value: %E\n", LDBL_MIN );

printf("Maximum long double positive value: %E\n", LDBL_MAX );

printf("Precision value: %d\n", LDBL_DIG );

return 0;

}

相关C语言技术点补充:

头文件 float.h 定义了宏,在程序中可以使用这些值和其他有关实数二进制表示的细节。

void 类型:void 类型指定没有可用的值,它通常用于以下三种情况。

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值