20.09.2015 Views

Programming in C

Kochan - ProgramminginC

Kochan - ProgramminginC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

64 Chapter 5 Program Loop<strong>in</strong>g<br />

6. A m<strong>in</strong>us sign placed <strong>in</strong> front of a field width specification causes the field to be<br />

displayed left-justified. Substitute the follow<strong>in</strong>g pr<strong>in</strong>tf statement for the correspond<strong>in</strong>g<br />

statement <strong>in</strong> Program 5.2, run the program, and compare the outputs produced<br />

by both programs.<br />

pr<strong>in</strong>tf ("%-2i<br />

%i\n", n, triangularNumber);<br />

7. A decimal po<strong>in</strong>t before the field width specification <strong>in</strong> a pr<strong>in</strong>tf statement has a<br />

special purpose.Try to determ<strong>in</strong>e its purpose by typ<strong>in</strong>g <strong>in</strong> and runn<strong>in</strong>g the follow<strong>in</strong>g<br />

program. Experiment by typ<strong>in</strong>g <strong>in</strong> different values each time you are<br />

prompted.<br />

#<strong>in</strong>clude <br />

<strong>in</strong>t ma<strong>in</strong> (void)<br />

{<br />

<strong>in</strong>t dollars, cents, count;<br />

}<br />

for ( count = 1; count

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!