|
|
A variable declaration begins with the data type (e.g., int), followed by the name of one or more variables of the same type that are separated by commas. A variable declaration can also contain an initial value, and always ends with a semicolon ( ;). Variable names must begin with a letter in C. A name can include letters, numbers, and the underscore ( _) character. Note that the C preprocessor is case-sensitive (recognizes uppercase and lowercase letters as being different). Below are some examples of variable declarations.
int n; /* declaring variable n as an integer */
int i1, i2; /* declaring variables i1 and i2 as integers */
float tmax = 0.; /* tmax is a floating point real number
that is initialized to 0 */
real average_temp = 0.0; /* average_temp is a real number initialized
to 0.0 */
|