小编Per*_*man的帖子

C程序每次打印0.00000但返回正确答案

我有一些非常简单的代码,我遇到了问题.这个程序只是计算一个人的体重(千克)并显示它.但是,每次运行时,打印的答案都会返回0.00000,但会返回正确的答案.有人看到我的代码有什么问题吗?

#include <stdio.h>
#include <math.h>

int main(void)
{ 
    float w;
    float const wc=0.454;

    printf("Enter your weight in pounds ");
    scanf("%f", &w); 

    float wk = w * wc;

    printf("Your weight in kilograms is: %f", &wk);

    return(wk);
} 
Run Code Online (Sandbox Code Playgroud)

c floating-point printf

-2
推荐指数
1
解决办法
174
查看次数

标签 统计

c ×1

floating-point ×1

printf ×1