2022.7.9补充:
去逛了一下别人的博客,发现自己的这个笔记欠缺的很多,不系统化,所以就这篇笔记进行补充

C语言数据类型

数据类型
char –字符类型
int –整数类型
short –短整形 短裤类型
long –长整形
long long –更长的整形
float –单精度浮点型
double –双精度浮点型
也就是说,咱们下边说到的double是双精度浮点型

image-1657339284733

浮点数 %f
整数 %d
当浮点数和整数放到一起运算时,C会将整数转换成浮点数,然后进行浮点数的运算

    (foot + inch / 12) * 0.3048;
    (foot + inch / 12.0) * 0.3048;

double 变量表示变量是一个浮点数

如果声明变量用的是double。那么我们用scanf输入它们的时候,就要使用%lf

转换身高案例

#include <stdio.h>

int main() {

    printf("请分别输入身高的英尺和英寸,""如输入5 7 表示5英尺7英寸");
    double foot;
    double inch;
    scanf("%lf %lf",&foot,&inch);
    printf("你的身高为%d英尺,%d英寸",foot,inch);
    printf("身高是%f米。 \n",((foot+inch/12)*0.348));
}