Thread: round

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    32
    I would like just to round my Avg in my output file.

    The Avg gets it value after a calculation and print its out put in a stream file. so now How do I round the Avg only.if my output statement like below;

    Code:
    outfile << Avg << Min << Max << endl;
    thank you

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    If you want rounding for output only try this
    Code:
    outfile << fixed << setprecision(2) << Avg << Min << Max << endl;
    you need to #include <iomanip>
    Kurt

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    32
    Thank you so much ZUK it is the perfect thing to my outfile.

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    14
    Quote Originally Posted by ZuK
    If you want rounding for output only try this
    Code:
    outfile << fixed << setprecision(2) << Avg << Min << Max << endl;
    you need to #include <iomanip>
    Kurt
    I was looking for this answer.. Thanks for very useful information.. I love this board..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 11-03-2008, 09:48 PM
  2. Fibonacci Formula, How to round in C++?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 10-15-2004, 10:47 AM
  3. I need some quick help with code.
    By stehigs321 in forum C Programming
    Replies: 35
    Last Post: 10-30-2003, 10:07 PM
  4. Someone help me with this game??
    By stehigs321 in forum Game Programming
    Replies: 15
    Last Post: 10-30-2003, 09:42 PM
  5. Please help with some coding..
    By stehigs321 in forum C Programming
    Replies: 2
    Last Post: 10-27-2003, 06:44 PM