Mega Code Archive

 
Categories / C++ / File
 

Construct a table of circular areas

#include <iostream> #include <sstream> #include <locale> #include <iomanip> using namespace std; int main() {   locale usloc("English_US");   ostringstream ostr;   // Give a new, empty string to ostr.   ostr.str(string());   // construct a table of circular areas.   ostr << setprecision(4) << showpoint << fixed << left;   ostr << "Diameter    Area\n";   cout << "A table of circular areas.\n";   for(int i=1; i < 10; ++i)     ostr << left << "   " << setw(6) << i << setw(8) << right << i*3.1416 << endl;   cout << ostr.str();   return 0; }