Floating Point Comparisons

int x = 12;
double a = 8.98, b = 24.489, c = 1234.8, d = 7.0;
  1. cout << a;
    cout << b;
    cout << c;
    cout << d;
    cout << endl;

  2. cout << setw(x) << a;
    cout << setw(x) << b;
    cout << setw(x) << c;
    cout << setw(x) << d;
    cout << endl;

  3. cout << setprecision(5);

  4. cout.setf(ios::showpoint);

  5. cout.setf(ios::fixed);
1 8.9824.4891234.87
2 8.98 24.489 1234.8 7
3 8.98 24.489 1234.8 7
4 8.9800 24.489 1234.8 7.0000
5 8.98000 24.48900 1234.80000 7.00000


Next page
Previous page
Go to Lesson 4 index.