Title: Identifiers
1Identifiers
- Programmer defined names or words.
- Naming Rules for identifiers
- alphanumerical
- underscore
- no leading digit(s)
- no space
2Identifiers - Examples
- Correct
- RowCount
- Return2Copies
- columncount
- ColumnCount
- columnCount
- Incorrect Names
- 2Copies
- row Count
- 3rdRow
3Basic Concept of Programming
- Basic Computer Operations
- Data Inputs
- Data Manipulations
- Data Outputs
4Data Manipulation
- Manipulating Data with
- Unknown values
- user inputs
- depend on the results of other manipulations
- Known values predetermined
- Constant values values will not change thru
the execution
5Data Storage
- Run time storage for unknown value
- Variable Identifier - Data Storage Reference
- names (identifier)
- data types (size of the data storage)
- scopes (duration or lifetime)
6Variable Name
- Naming Rules for Variables
- alphanumerical
- no leading digit
- no space
- underscore
- Naming Conventions
- lowercase for first character
- Uppercase for the character of a word
7Variable Name - Examples
- Correct Names
- RowCount
- Return2Copies
- columncount
- Preferred
- rowCount
- return2Copies
- columnCount
- Incorrect Names
- 2Copies
- row Count
- 3rdRow
8Data Types
- Primitive Data Types
- int
- char
- float
9Define a Variable
- Syntax
- Data_Type Variable_name
- Data_Type Variable_name Value
- Examples
- int iCount
- char iFirstCharacter
- char iC A
- int iNumber 0
- float fFlat 17.5
10Scope of a Variable
- Scopes
- block scope
- instance scope will talk more about this later
- class scope will talk more about this later
11Scope - block
- Scope
- between the most inner block of
- starts right after the definition of the variable
12Block Scope - Example
int iTotal int iSteps int iBegin 0 int
iEnd 10 //data manipulations //end of scopes
of iBegin and iEnd //data manipulations //end of
scopes of iSteps and iTotal
13Block Scope Example cont.
14Scope - instance
- Instance scope variables
- properties
- non-static
15Scope - class
- Class scope variables
- unique for all instances of the same class
- static variables
16More on Data Manipulations
- Basic operations
- value assignment operator
- addition operator
- subtraction operator -
- multiplication operator
- division operator /
17Simple statements
int iBegin 0 int iEnd 10 int iSteps int
iTotal iSteps iEnd iBegin iTotal 5
iSteps //note a complete statement ends with
18Basic Structures
- Structured Programming in C/C
- sequence
- decision/selection/testing
- iteration/repetition/looping
19Sequence
//Do this instruction
int iCount 0 int iRow 0 int iColumn 0
20Decision/Selection/Testing
21Iteration/Repetition/Looping