-
decimal alignment
help!
I need to align decimal places of my output that's printed in fixed notation to 5 decimal places!!
I used this:
/*
double a =1.0000
printf ("\t\t\t\t%8.3f\n", a
*/
but it only took the precision to 3, and when i changed the 8.3 to 8.5 it was't lined up....
ahhhhhhhh
can anyone point me at the correct code?
Thanks
scuba22
-
cout <<setiosflags (ios::showpoint | ios::fixed | ios::right | setprecision(number));
thats the way i know how to do it
-
this is the error i get....
- the numbers still aren't aligning
i am using
#include<iostream>
#include<iomanip>
using namespace std;
is there another header i am missing????
(Ihave been at this for 4 hours)
just trying to align my silly output, ready to split in2 :-(
scuba22
-
the error:
sorry-
C:\Program Files\Microsoft Visual Studio\MyProjects\HW_926a\HW_926a.cpp(15) : error C2677: binary '|' : no global operator defined which takes type 'struct std::_Smanip<int>' (or there is no acceptable conversion)
-
think its my fault, wrong syntax: here ya go try this:
cout <<setiosflags (ios::fixed | ios::showpoint | ios::right) <<setprecision(number)
not missing a header, that had to of been why it yelled but the pipe char |
-
thanks for trying --it's still not right jusified....
what i want to do is align output's decimal points...
it's so not happening.
the program calculates circumference, area, volume, surface area of a circle/sphere....to 5 decimal places....
and i cannot got those decimals lined up!
-
you need setw(number) to create a right margin. This goes on the same line like this:
Code:
cout<<setw(10)<<var1;
cout<<setw(10)<<radius;
-
THANKS...with alittle modification it's working!