Skip to main content
Logo image

Chapter 11 Formatted Input/Output and Program Style

In this chapter, we will take a closer look at how to format your code’s output. Maybe you only want floats to print with two digits past the decimal point? Maybe you would like to print a column of number in a right-justified manner? Or you’d like your numbers to be left-justified when they print? Many stylistic options exist in C to produce a clean and neat output, and we will explore all the various options!
Similarly, the way in which you style your code itself (indentations, line breaks, variable names, etc) will greatly affect how easily others will be able to understand it, as well as how quickly you will be able to remember what you did when looking back at a piece of your own code. We will look at some best practices to guide your stylistic choices while coding.