?
Solved

cout to two decimal points?

Posted on 2003-03-20
3
Medium Priority
?
197 Views
Last Modified: 2010-04-01
I need to know how to cout a statement in currency, I mean to two decimal points such as
input >> 6.54657
output << 6.55

Help would be greatly appreciated, thx for a program for a school course.
The Dodgeman
0
Comment
Question by:Dodgeman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
farbs earned 200 total points
ID: 8178876
output << setiosflags (ios::fixed | ios::showpoint) << setprecision(2)<< (your varible or number here);
0
 
LVL 2

Expert Comment

by:constructor
ID: 8180045
farbs' technique is okay, but it should be noted that you only need to use these manipulators, which reside in <iomanip>, once. To set the field with use setw which on the other hand must be used for each output separately.
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9517253
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: farbs

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question