这个程序为什么输出的结果c都是1。

#include <stdio.h>
int main()
{
float a,b,c;
scanf("%lf,%lf",&a,&b);
c=a*b;
printf("c=%d",c);
return 0;
}

printf("c=%d",c);

改成

printf("c=%f",c);

c 是 float 类型要用 %f 输出
%d 只能输出整数类型


#include <stdio.h>
int main()
{
    float a,b,c;
    scanf("%f,%f",&a,&b);
    c=a*b;
    printf("c=%f",c);
    return 0;
}

img

如有帮助,望采纳!谢谢!