Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constant: value does not change

Similar presentations


Presentation on theme: "Constant: value does not change"— Presentation transcript:

1 Constant: value does not change
Variable: a memory location whose contents can vary; also called an identifier Each programming language has it own rules for naming identifiers, including: Legal characters Maximum length Use of upper or lower case Variable name must be a single word, but can be formed from several words rate, interestRate, interest_rate Constant: value does not change Values that do not change while the program is running Have identifiers, and can be used like variables for calculations, but cannot be assigned new values Literal: is use of data itself (ex: pi – )

2 Variables, Constants and Literals
Variable: Name of a collection of memory cells that are treated as a unit. Contains data that can be changed by the programmer. A container for data that can be changed. Constant: A named data item that contains information that the programmer does not change. The information stays the same throughout the program execution. A container for data that does not change. Literal: A constant whose name is the written representation of its value. Example: add 50 to total_accumulator

3 Variables, Constants and Literals
Variables: Contains data that can be changed - OR - Container

4 Variables, Constants and Literals
Constant: Contains data that can NOT be changed - OR - - OR - Container of Milk

5 Declaring Variables Assign identifiers to memory locations
Specify the name and data type Use meaningful names and follow standards Prefixes may be used to group related variables Declare a variable for each field in a data file

6 Declaring Variables Initializing (or defining) the variable: providing an initial value Some languages provide default initial values Other languages leave variables with an unknown or garbage value Variables representing data fields in files do not need to be initialized

7 Declaring Variables Local variables: declared within a module
Global variables: declared at the beginning of the program, and used in all modules Annotation box: flowchart symbol containing notes Data Dictionary: list of variables used in a program, with their type, size, and description


Download ppt "Constant: value does not change"

Similar presentations


Ads by Google