小编Cel*_*ste的帖子

C初学者,代码输出不正确

所以我对编码很新,这是我第一次使用scanf和printf.对于我的家庭作业,我们应该创建一个计算燃油效率的程序,单位为mpg,升数为每100km.最后的答案只应该有2个小数点......但这是另一个故事.,P

现在,该程序允许我输入第一部分的值(多少英里),但是,一旦我点击输入它跳过我的代码的末尾并吐出一个(看似)随机数?

#include <stdio.h> /* tells computer where to find definitions for printf and scanf */
#define KMS_PER_MILE 1.61 /* conversion constant for miles to kms */
#define LIT_PER_GAL 3.79 /* conversion constant for gallons to liters */

int main(void)
{
    double miles, /* input - distance in miles. */
    gallons, /* input - gallons consumed */
    mpg, /* output - miles per gallon */
    kms, /* output - kilometers */
    liters, /* output - liters */
    lpkm; /* output …
Run Code Online (Sandbox Code Playgroud)

c printf scanf output

0
推荐指数
1
解决办法
856
查看次数

标签 统计

c ×1

output ×1

printf ×1

scanf ×1