Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

cout to two decimal points?

Posted on 2003-03-20
3
Medium Priority
?
200 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
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

581 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