decimal places for HW

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • justlearning
    New Member
    • Oct 2006
    • 2

    decimal places for HW

    I have this homework problem that needs the array to print out like 1.0, 2.0 ect... I can get it to print out 1,2 ect...I was wondering if someone could tell me how to get it with the one decimal place. I am using doubles and I tried set precision.

    Thank you
    justlearning
  • m013690
    New Member
    • Sep 2006
    • 23

    #2
    there is an output set mode function that works for floats as opposed to doubles.

    showpoint is the function, and it combines with setprecision. as in:

    cout << setprecision (3) << showpoint << 1.00;

    setprecision requires #include <iomanip>, and showpoint just requires #include <iostream>

    Comment

    Working...