Chapter 02
Chapter 02
variable
data type name
char letter;
– Is used to reference a location in memory where a
value can be stored
– Variable must be defined before it can be used
– This value can be changed (i.e., can “vary”)
total_Sales Yes
H e l l o \0
0 1 2 3 4 5
• Initializing a variable
– Gives an initial value to a variable at the time
it is created
– Can initialize some or all variables of
definition
int length = 12;
int width = 7, height = 5, area;
- subtraction ans = 7 - 3; 4
* multiplication ans = 7 * 3; 21
/ division ans = 7 / 3; 2
% modulus ans = 7 % 3; 1