Variable Declarations

To declare a variable, specify a data type and name. Optionally you may provide an initializer.

Details

Details are as follows:

Examples

The following example declares an integer variable named counter.

int counter;

The following example declares several integer variables named x, y, and z.

int x,y,z;

The following example declares an integer variable named counter and initializes its value to zero.

int counter = 0;

The following example declares a double-precision variable named acceleration and initializes its value to 9.80665.

double acceleration = 9.80665;

The following example declares a string variable named nameprefix and initializes its value to Quadrant.


string nameprefix = "Quadrant";