C语言基础-2、数据类型

一、计算

  • 整数除法(只保留整数部分)
#include <stdio.h>
int main()
{
    printf("%d\n",14/3);
    return 0;
}

  • 整数除法(保留小数点后面数据)
#include <stdio.h>
int main()
{
    printf("%f\n",14/3.0);
    return 0;
}

*浮点数除法

#include <stdio.h>
int main()
{
    printf("请分别输入身高的英尺和英寸,""如输入\"5 7\"表示5英尺7英寸:");
    double foot;
    double inch;
    scanf("%lf %lf",&foot,&inch);
    printf("身高是%f米n",((foot+inch/12)*0.3048));
    return 0;
}
posted @ 2024-01-22 22:29  吃粥要吃烫的  阅读(27)  评论(0)    收藏  举报