我不知道为什么当我执行这个程序时浮动不能打印确切的值的原因。浮动不能正常工作
#include <iostream>
using namespace std;
int main(){
int a, b;
float x;
cout << "Input the value for a: ";
cin >> a;
cout << "Input the value for b: ";
cin >> b;
x = - b/a;
printf("The value of x is: %.2f",x);
//cout << "The value of x is: " << x;
}
我想至少在我的输入2和10 b的结果应该是0.20, 程序显示0.00只
不会给出商。所以结果仍然是5 – jonju
所以我不能得到浮动答案像1.5如果我的操作数是整数? – Marr