October 2008
Beginner to intermediate
680 pages
16h 48m
English
As previously stated, before a variable can be used in a program, the type and name of the variable must be declared. An initial value can be supplied when a variable is first declared, or the variable can be assigned a value later in the program. For example, the following code snippet declares two simple type variables. The first variable, of type int, is given an initial value when the variable is declared. The second variable, of type double, is declared and then assigned a value on a subsequent line of code.
int count = 3; double total; // intervening code...details omitted total = 34.3;
A value can be assigned to a bool variable using the true or false keywords:
bool blah; blah = true;
Boolean variables are often used as ...
Read now
Unlock full access