I was trying to do some sums and i faced this problem , i wonder if there a way fix it?
here's my code
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
float a=(3.0/2.0)+2;          // a = 3.5
 float b=(5.5/2.0)+2;         // b = 4.8
  float c=((a+b)/2.0)+2;      // c = 6.1
   float d=((3.5+4.8)/2)+2;   // d = 6.2
   cout<<"a = "<<fixed << setprecision(1)<<a<<endl;
   cout<<"b = "<<fixed << setprecision(1)<<b<<endl;
  cout<<"c = "<<fixed << setprecision(1)<<c<<endl;
 cout<<"d = "<<fixed << setprecision(1)<<d<<endl;
system("pause");
return 0;
}
the result will be:
a = 3.5
b = 4.8
c = 6.1
d = 6.2
How can i make c= 6.2 ?
