Chapter 2: Structure of a C Program

David L. Chopp · Society for Industrial and Applied Mathematics eBooks · 2019

Those already familiar with a programming language will no doubt find many parallels with C. Languages such as C++ and Java have very strong similarities, even including much of the syntax, but all languages have the same underlying structure. No matter what language is used, it is absolutely essential to comment the code. To be an effective programmer, code should be made reusable, and it is reusable only if it is clear what each function needs for input and what it produces for output. It is not reusable if its purpose and usage are easily forgotten. When working in a team, it is even more essential that comments are clear and consistent so that others can reliably use your work. Careful and frequent comments can help the reader understand the logic of the program so that if changes are necessary later, it can be done easily and confidently. This chapter introduces the core components of a program: where it starts, how input values can be included on the command line, and how to finish. It also covers the different styles of comments and what is good practice for commenting your code.

Read the paper · More papers on PaperTik