September 2001
Beginner
970 pages
23h 20m
English
The first sample program was pretty easy, and the next example, shown in Listing 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);
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.
First, the program begins with a comment (using the new comment style) identifying the filename and the purpose of the program. This ...
Read now
Unlock full access