September 2001
Beginner
970 pages
23h 20m
English
When you develop a program, note the variables you need and which type they should be. Most likely, you can use int or possibly float for the numbers and char for the characters. Declare them at the beginning of the function that uses them. Choose a name for the variable that suggests its meaning. When you initialize a variable, match the constant type to the variable type.
int apples = 3; /* RIGHT */ int oranges = 3.0; /* POOR FORM */
C is more forgiving about type mismatches than, say, Pascal. C compilers allow the second initialization, but they might complain, particularly if you have activated a higher warning level. It is best not to develop sloppy habits.
When you initialize a variable of one numeric type to a value ...
Read now
Unlock full access