Exam I is on Thursday. anything else.

advertisement
Exam I is on Thursday.
In your Wed. labs, the TAs can answer questions about the Review Questions or
anything else.
Exam is about 15 questions: 1/3 short answer, 1/3 code reading, 1/3 code writing.
Formatted Output:
You do this with the printf() function:
printf ( <format string>, <expression 1>, <expression 2>, .... );
The format string tells the system the format in which you want the values of the
expressions printed.
The format string can contain arbitrary characters that you want printed (labels and
things like that), but it also contains one format code for each expression to be
printed.
The format codes begin with "%".
There are many format codes; these are just the most common. Look in the printf
documentation to find out about more.
%Wd = this means print an integer in a field of width at least W. For example %4d
means to print an integer in a field of width at least 4. If the integer doesn't take 4
digits, it will be right justified in the field of 4. If it takes more than 4 digits, the
field will be expanded as much as necessary.
%W.Df = format for a floating-point number. The number is printed right-justified in
a field of width W with D digits after the decimal point. So %6.3f prints the number
in a field of size 6 with 3 digits after the decimal.
%Ws = format to print a (variable or computed) Cstring in a field of length W, right-
justified.
%-Wd, %-W.Df, %-Ws = the same but print left-justified.
Loan Example: a nice example of stepwise development of a program.
The program is written first in "pseudo-code" (programming language-like English),
and then translated to the actual programming language (C++).
Download