September 1998
Intermediate to advanced
848 pages
20h 13m
English
The first sample program was easy, and the next example, shown inListing 2.2, isn't much harder.
/* 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);
return 0;
}
|
What's new? We supplied a program description, declared multiple variables, did some multiplication, and printed the values of two variables. Let's examine these points in more detail.
First, the program begins with a comment identifying the filename and the purpose of the program. This kind of program documentation takes but a moment to do and is helpful later on when you ...
Read now
Unlock full access