I'm adding 2 double values but the output is an integer value.
#include<iotream>
int main()
{
double d = 4.0;
double sd = 0;
cin >> sd;
std::fixed;
cout << std::setprecision(2) << d + sd << endl;
return 0;
}
Input : 4.0 + 4.0
Output : 8 //Expected Output 8.0
Can anyone help me understand what am I missing ?
Last edited on
Well you're missing the half-dozen or so other lines which would be a nice complete program we can copy/paste/test for ourselves.
A couple of random lines out of context, and a "I did foo" doesn't really tell much.
Hey Salem,
I've updated the post.
Thanks for the solution JL Borges.