C++ double type control for loop

Description

C++ double type control for loop

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()/*from   w ww .j a  va  2  s.c o m*/
{
   double x, y;
   cout << "x value      y value\n" << "-------     ---------\n";
   cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(5);
   for (x = 2.0; x <= 6.0; x = x + 0.5)
   {
      y = 10.0 * pow(x,2.0) + 3.0 * x - 2.0;
      cout << setw(7) <<  x << setw(14) << y << endl;
   }
   return 0;
}



PreviousNext

Related