下面是我的代码:
#include <stdio.h>
int main()
{
int inches = 0;
int yards = 0;
int feet = 0;
const int inches per foot = 12;
const int feet_per yard = 3;
printf("Enter a distance in inches: ");
scanf ("%d", &inches);
feet = inches/inches_per_foot;
yards = feet/feet_per_yard; feet %= feet_per_yard;
inches %= inches_per_foot;
printf("That is equivalent to %d yards %d feet and %d inches.\n",
printf("or %d centimeters\n", inches*2.54);
}
输入:输入距离(英寸):10
产量:相当于0码0英尺10英寸,或1717986918厘米。
那么,1717986918是什么?
1条答案
按热度按时间g0czyy6m1#
那么,1717986918是什么?
这是当你试图打印一个
double
时发生的事情,就好像它是一个int
一样。由于
inches *2.54
涉及与浮点数相乘,因此inches
隐式转换为double
,结果为double
。使用%f
打印double