这个简单的代码有点问题。C中的双值错误
我已经尝试过不同类型的铸件,但是我在这里没有任何问题。如果有人告诉我为什么总是打印0.0000000或类似的原因,我会提前感到遗憾和感谢。
#include<stdio.h>
main()
{
double num1,num5;
printf ("Hello user\n");
printf ("Let the thickness of black and white brick are same and the value
is 2m\nAnd the gap between them is 1m\n");
printf ("\nEnter the length of the road:\n");
scanf ("%lf",&num1);
num5 = ((2/5)*num1);
printf ("%lf",num5);
return 0;
}
重复与https://stackoverflow.com/questions/40443602/c-double-not-working-as-expect/40443639# 40443639和https://stackoverflow.com/questions/16221776/why-dividing-two-integers-doesnt-get-a-float –
[分隔1/n总是返回0.0](https://stackoverflow.com/questions/13331054/divide-1-n-always-returns-0-0) –