- [Instructor] In this exercise, we'd like you
to print the two floating point numbers you see here,
and we would like each of those
to be displayed preceded by it's sign,
so we want to force a plus sign on the first value here
in a 10-character field with thousands separators,
and we want their decimal points to be aligned vertically
with two digits to the right of each of those.
So go ahead and pause the video to give that a shot,
then come back to see the answer.
Okay, let's go ahead and reveal that,
and as you can see here,
we are doing a couple of placeholders
in our format string that will be printed.
For the first value, we wanted to force it
to display it's sign no matter what.
We're going to do this in a field of 10.
We've got the comma to indicate
that we want to do the thousands separator
and we want two digits to the right of the decimal point
for this floating point number
and then we used the same specifier for the other value
even though it's a negative value,
we still put in the plus sign here, but of course,
a plus sign will not appear because it's negative.
So let's go ahead and execute that
and you can see a couple of things here.
First of all, the two digits
to the right of the decimal point,
remember the numbers are right aligned automatically
in format specifiers unless you indicate otherwise,
so the fields of 10 were a little bit wider
than each of the two values in this case
and also notice the comma separators
and the plus sign before the positive value.