|
|
All variables must be declared prior to use. Here is the general form of a declaration:
type variable_name;
For example, to declare x to be a float, y to be an integer, and ch to be a character, you would write
float x; int y; char ch;
You can declare more than one variable of a type by using a comma-separated list. For example, the following statement declares three integers:
int a, b, c;
A variable can be initialized by following its name with an equal sign and an initial value. For example, this declaration assigns count an initial value of 100:
int count = 100;
An initializer can be any expression that is valid when the variable is declared. This includes other variables and function calls. However, in C, global variables and static local variables must be initialized using only constant expressions.
|
|