Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decimal positioning

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I have a question.
In C++, win 32 console application.
I have made a program to take input from a user.
That input is a float datatype. Its going to take that input and do a calculation, cout output and repeat it self
until some point. My question is how do I get C++ to line
up the decimal numbers. Well, you probably dont know what the heck I mean but here is an example.

Example--> You have a group of decimal numbers.
Lets say, 1.2 ,2.7,5.8,3.4, ...ect.
And My question is how do I get it to line up the decimal points, like this-->
1.2
2.7
5.8
3.4

*Notice how the decimal points are line up in a column?
Thats how I want it to look but I cant seem to get it that way. Please help :)It may look different from what i posted.
 
You could #include <iomanip.h> and then
...
cout << setw(6) << your_float << endl;
...

and it should be done in a loop.
Best Regards,

aphrodita@mail.krovatka.ru {uiuc rules}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top