I am trying to get a value output to two decimal places using code that works in MS Visual C++:
cout << fixed;
cout.precision(2);
but in bloodshed I am getting errors that "Fixed" is undelcared. Do I need to include another libary other then cmath? In MS C++ need to add the line "using namespace std;" after my #includes, but bloodshed dosen't seem to reconize that line.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to get a value output to two decimal places using code that works in MS Visual C++:
cout << fixed;
cout.precision(2);
but in bloodshed I am getting errors that "Fixed" is undelcared. Do I need to include another libary other then cmath? In MS C++ need to add the line "using namespace std;" after my #includes, but bloodshed dosen't seem to reconize that line.
Thanks.
Here is something i put together that uses what you asked about.
Could be better,but i did it for demo not great style...
#include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main()
{
cout.setf(ios::fixed); // " "
cout.precision(2) ; // both affect all below
double salePrice = 0;
double discnt = 0;
double oPFactor = 1;
cout <<"Test Program "<< "\n";
cout << " Enter sale price and the Discount% as: .10 = 10%" << "\n \n";
cout << " Enter the salePrice " << "\n \n";
cout << ": ";
cin >> salePrice;
cout << "\n";
cout << " Enter the Discount " << "\n \n";
cout << ": ";
cin >> discnt;
cout << "\n";
double oPrice = (salePrice * (oPFactor/(oPFactor-discnt)));
cout << "The Price befoe the Discount was: "
<< setw(14)<< oPrice << "\n";
system("PAUSE");
return 0;
}
j@ck_
Great style or not it works perfect, Thanks.