Scanf for double not working in Dev C++

后端 未结 4 1485
忘掉有多难
忘掉有多难 2021-01-27 11:51

I am having problem with floating point numbers. I think something is clashing here.

The output is :

\"Scre

4条回答
  •  -上瘾入骨i
    2021-01-27 12:38

    You are using the wrong format specifier in the scanf and doing this will result in UB(Undefined Behaviour).The correct format specifier for a double is %lf while that of a float is %f. So Just change your scanf to

    scanf("%lf",&y);
    

提交回复
热议问题