Faculty Supervisor: Al Day
Some material is derived from a lesson by: Dr. James Hilliard
HTML Documentation by: Michelle Roberts
Last Updated 7/24/96
# is replaced by any whole number (e.g. 5)
*Discussed in a Later Lesson.
For double:
COMPUTER INPUT/OUTPUT: NUMERICAL![]()
i) Formatted input
ii) Default inputi) Formatted output
ii) Default output
FORMAT![]()
Instructs the computer how to interpret numbers in a data record
(input).
Instructs the computer how and where to print numbers or letters in a
data record (write).CONVERSION SPECIFICATION
Identifies type and length of variable output.
FORMATTED OUTPUT![]()

fp : File pointer variable
cs : Conversion Specification for corresponding variable
var : Variable names
Mesg : Any string of characters before or after the conversion
specification
FORMAT FOR DIFFERENT VARIABLE TYPES
![]()

# and #.# are completely
optional and one (and/or the other for #.#) may be omitted for
default output.
For int & double:
HOW TO USE #'S FOR FORMATTED OUTPUT
![]()
The first # is the placeholder (or field width--the minimum
number of columns reserved for the number. Numbers of smaller width than
the placeholder are right-justified within the field reserved for the
number.
The second # is the number of decimal places desired in the
output.
Extra decimal places are rounded off. If
the field width is too small, the number is printed with no blanks preceding
it, and the number of columns used varies with the size of the number in
its printed form.