Topic 3 - Formatted Input/Output Flashcards
What is a conversion specification?
A placeholder.
What is %d used for
int values as a conversion specifier
What is %f used for
float values as a conversion specifier
Too many conversion specifications _____ produce meaningless output.
will
Too few conversion specifications _____ produce meaningless output
might
Incorrect specification ____ produce meaningless output
will
In the conversion specification form: %m.pX (or %-m.pX) - what is m?
minimum field width - specifies the minimum number of characters to print
What happens when the value to be printed requires fewer than m characters?
It will be right-justified within the field and space characters will be inserted to its left
What does putting a minis sign in front of m do?
causes left justification in the event that the value to be printed requires fewer than m characters. Space characters are then inserted to the right of the value instead.
What happens if the value to be printed requires more than m characters?
the field with automatically expands to the necessary size.
The main of p in %m.pX depends on what.
The choice of X, the conversion specifier.
What does “p” indicate for %d specifier?
The minimum number of digits to be displayed - extra zeros are added to the beginning of the number, if necessary
If p is omitted with %d, what happens.
P is assumed to be 1.
What does p indicate for %f?
%e?
%f - fixed decimal format - p indicates the number of digits after the decimal point
%e - exponential format - p as the same meaning as for the f specified
What does p indicate for %g?
%g - either exponential format or fixed decimal format, depending on the number to b printed - e format is selected in case of too small numbers