Taking Another Step
The first sample program was pretty easy, and the next example, shown in Listing 2.2, isn't much harder.
Listing 2.2. The fathm_ft.c Program
// fathm_ft.c -- converts 2 fathoms to feet #include <stdio.h> int main(void) { int feet, fathoms; fathoms = 2; feet = 6 * fathoms; printf("There are %d feet in %d fathoms!\n", feet, fathoms); printf("Yes, I said %d feet!\n", 6 * fathoms); return 0; } |
What's new? The code provides a program description, declares multiple variables, does some multiplication, and prints the values of two variables. Let's examine these points in more detail.
Documentation
First, the program begins with a comment (using the new comment style) identifying the filename and the purpose of the program. This ...
Get C Primer Plus, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.