# C 程序：查找`int`，`float`，`double`和`char`的大小

> 原文： [https://beginnersbook.com/2017/09/c-program-to-find-the-size-of-int-float-double-andchar_](https://beginnersbook.com/2017/09/c-program-to-find-the-size-of-int-float-double-and-char/)

该程序查找数据类型的大小，如`char`，`int`，`float`，`double`。

## 示例：用于在 C 中查找数据类型大小的程序

在这个程序中，我们使用`sizeof()`运算符来查找数据类型的大小。当`sizeof` 与原始数据类型（如`int`，`float`，`double`和`char`）一起使用时，它将返回分配给它们的内存量。

```c
#include<stdio.h>
int main()
{
    printf("Size of char: %ld byte\n",sizeof(char));
    printf("Size of int: %ld bytes\n",sizeof(int));
    printf("Size of float: %ld bytes\n",sizeof(float));
    printf("Size of double: %ld bytes", sizeof(double));
    return 0;
}
```

输出：

```c
Size of char: 1 byte
Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
```

看看这些相关的 C 程序：

1.  [C 程序：相加两个数字](https://beginnersbook.com/2017/09/c-program-to-add-two-numbers/)
2.  [C 程序：查找数组中的元素数](https://beginnersbook.com/2017/09/c-program-to-find-the-number-of-elements-in-an-array/)
3.  [C 程序：检查数字是正数还是负数](https://beginnersbook.com/2015/02/c-program-to-check-whether-the-given-integer-is-positive-or-negative/)
4.  [C 程序：按升序排列数字](https://beginnersbook.com/2015/02/c-program-to-arrange-numbers-in-ascending-order/)
5.  [C 程序：查找商和余数](https://beginnersbook.com/2017/09/c-program-to-find-quotient-and-remainder/)