Identifiers - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Identifiers

Description:

Title: e-business: present & future Author: Ming (Michael) Chang Last modified by: Michael D Chang Created Date: 2/8/2002 3:38:00 PM Document presentation format – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 22
Provided by: MingM4
Category:

less

Transcript and Presenter's Notes

Title: Identifiers


1
Identifiers
  • Programmer defined names or words.
  • Naming Rules for identifiers
  • alphanumerical
  • underscore
  • no leading digit(s)
  • no space

2
Identifiers - Examples
  • Correct
  • RowCount
  • Return2Copies
  • columncount
  • ColumnCount
  • columnCount
  • Incorrect Names
  • 2Copies
  • row Count
  • 3rdRow

3
Basic Concept of Programming
  • Basic Computer Operations
  • Data Inputs
  • Data Manipulations
  • Data Outputs

4
Data 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

5
Data 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)

6
Variable 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

7
Variable Name - Examples
  • Correct Names
  • RowCount
  • Return2Copies
  • columncount
  • Preferred
  • rowCount
  • return2Copies
  • columnCount
  • Incorrect Names
  • 2Copies
  • row Count
  • 3rdRow

8
Data Types
  • Primitive Data Types
  • int
  • char
  • float

9
Define 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

10
Scope of a Variable
  • Scopes
  • block scope
  • instance scope will talk more about this later
  • class scope will talk more about this later

11
Scope - block
  • Scope
  • between the most inner block of
  • starts right after the definition of the variable

12
Block 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
13
Block Scope Example cont.
14
Scope - instance
  • Instance scope variables
  • properties
  • non-static

15
Scope - class
  • Class scope variables
  • unique for all instances of the same class
  • static variables

16
More on Data Manipulations
  • Basic operations
  • value assignment operator
  • addition operator
  • subtraction operator -
  • multiplication operator
  • division operator /

17
Simple statements
int iBegin 0 int iEnd 10 int iSteps int
iTotal iSteps iEnd iBegin iTotal 5
iSteps //note a complete statement ends with
18
Basic Structures
  • Structured Programming in C/C
  • sequence
  • decision/selection/testing
  • iteration/repetition/looping

19
Sequence
//Do this instruction
int iCount 0 int iRow 0 int iColumn 0
20
Decision/Selection/Testing
21
Iteration/Repetition/Looping
Write a Comment
User Comments (0)
About PowerShow.com