Identifier
ITC112
Computer Programming 1
What is variable?
▰ A variable is a:
❑ Placeholder of information that can usually be
changed at run-time
▰ Variables allow you to:
❑ Store information
❑ Retrieve the stored information
❑ Manipulate the stored information
2
IDENTIFIERS / VARIABLES
▰ Identifiers may consists of:
❑ Letters (a-z, A-Z)
❑ Digits [0-9]
❑ Underscore “_”
▰ Identifiers
❑ Can begin only with a letter or an underscore
❑ Cannot be a C# keyword
3
Variable (cont…)
▰ No other special characters are allowed including
space
▰ Variable names are case sensitive
❑ A and a are different.
▰ Identifiers
❑ Should have a descriptive name
❑ Should be neither too long nor too short
4
Declaring Variables
▰ When declaring a variable we:
❑ Specify its type
❑ Specify its name (called identifier)
❑ May give it an initial value
▰ The syntax is the following:
▰ example
5
<data_type> <identifier> [= <initialization>];
int height = 200;
Variable (cont…)
▰ Variables are data that will keep on changing
▰ Declaration
<<Data type>> <<variable name>>;
int a;
▰ Definition
<<varname>>=<<value>>;
a=10;
▰ Usage
<<varname>>
a=a+1; //increments the value of a by 1
6
Variable (cont…)
▰ Examples of correct identifiers:
▰ Examples of incorrect identifiers:
7
int New = 2; // Here N is capital
int _2Pac; // This identifiers begins with _
string nosApab = “Hello”; // Unicode symbols used
// The following is more appropriate:
string greeting = “Hello”;
int n= 100; // Undescriptive
int numberOfClients = 100; // Descriptive
// Overdescriptive identifier:
int numberOfPrivateClientOfTheFirm = 100;
int new; // new is a keyword
int 2Pac; // cannot begin with a digit
Declaring (cont…)
▰ Computers are machines that process data
❑ Data is stored in the computer memory in variables
❑ Variables have name, data type and value.
▰ Example of variable definition and assignment in C#
int counter = 5;
8
Variable name
Variable value
Data type
Assignment
operator
Declaring (cont…)
▰ Examples of variable declarations:
int myAge = 25;
▰ The equal sign (=) is an assignment operator
▰ The assignment operator works from right to left
▰ An assignment made when a variable is declared is an initialization
▰ It is not necessary to initialize a variable during a declaration.
▰ For example int myAge; is a valid declaration
9
Declaring (cont…)
▰ Examples of multiple variable declarations:
▻ int myAge = 25;
int yourAge = 19;
▻ int myAge = 25, your Age = 19;
▰ Declarations of variables of the same type can be separated by
commas. However, separate statements are used when declaring
variables of different types
▻ int myAge, yourAge;
double mySalary, yourSalary;
10
Displaying Variable Values
▰ You can display variable values by using the variable name within a
WriteLine() method call
11
Displaying (cont…)
▰ Program that displays a string and a variable value
12
THANKS!
Any questions?
You can find me at
delfirome@gmail.com
Learning Activities
Learning Activities

More Related Content

PDF
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
KEY
.NET Variables and Data Types
PPTX
PLF-Lesson tsu lecture time 2 units-2.pptx
PPTX
Variable_DatadsadasdasdasdasdasdaType.pptx
PPTX
C Language presentation
PPTX
Lesson 3: Variables and Expressions
PPTX
02. Primitive Data Types and Variables
DOCX
MaciasWinter 2020ENG 107Project #2A Year in Gami.docx
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
.NET Variables and Data Types
PLF-Lesson tsu lecture time 2 units-2.pptx
Variable_DatadsadasdasdasdasdasdaType.pptx
C Language presentation
Lesson 3: Variables and Expressions
02. Primitive Data Types and Variables
MaciasWinter 2020ENG 107Project #2A Year in Gami.docx

Similar to Week 08 - Identifier.pdf (20)

PPTX
Chapter 3.1
PPT
1. overview of c
PPTX
Module 1:Introduction
PPTX
Compiler: Programming Language= Assignments and statements
PPT
02 Primitive data types and variables
PPTX
C# lecture 2: Literals , Variables and Data Types in C#
PDF
Using Variables in Programming
PDF
Using Variables in Programming
PPT
PPT
Introduction To C
PDF
Lecture 4 constants_variables
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
PPTX
High quality program element that are founf in programming logic and design
PPTX
Chapter3: fundamental programming
PPTX
datatypes_variables_constants
PDF
Using Variables in Programming
PPTX
Visual Programming
ODP
CProgrammingTutorial
PPTX
different data types used in programming VB .pptx
PDF
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
Chapter 3.1
1. overview of c
Module 1:Introduction
Compiler: Programming Language= Assignments and statements
02 Primitive data types and variables
C# lecture 2: Literals , Variables and Data Types in C#
Using Variables in Programming
Using Variables in Programming
Introduction To C
Lecture 4 constants_variables
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
High quality program element that are founf in programming logic and design
Chapter3: fundamental programming
datatypes_variables_constants
Using Variables in Programming
Visual Programming
CProgrammingTutorial
different data types used in programming VB .pptx
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
Ad

Recently uploaded (20)

PPT
Geologic Time for studying geology for geologist
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
CloudStack 4.21: First Look Webinar slides
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Comparative analysis of machine learning models for fake news detection in so...
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Getting started with AI Agents and Multi-Agent Systems
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Five Habits of High-Impact Board Members
DOCX
search engine optimization ppt fir known well about this
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
STKI Israel Market Study 2025 version august
Geologic Time for studying geology for geologist
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
CloudStack 4.21: First Look Webinar slides
1 - Historical Antecedents, Social Consideration.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
OpenACC and Open Hackathons Monthly Highlights July 2025
2018-HIPAA-Renewal-Training for executives
Zenith AI: Advanced Artificial Intelligence
NewMind AI Weekly Chronicles – August ’25 Week III
Comparative analysis of machine learning models for fake news detection in so...
Enhancing plagiarism detection using data pre-processing and machine learning...
A proposed approach for plagiarism detection in Myanmar Unicode text
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Microsoft Excel 365/2024 Beginner's training
Getting started with AI Agents and Multi-Agent Systems
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Five Habits of High-Impact Board Members
search engine optimization ppt fir known well about this
Improvisation in detection of pomegranate leaf disease using transfer learni...
STKI Israel Market Study 2025 version august
Ad

Week 08 - Identifier.pdf

  • 2. What is variable? ▰ A variable is a: ❑ Placeholder of information that can usually be changed at run-time ▰ Variables allow you to: ❑ Store information ❑ Retrieve the stored information ❑ Manipulate the stored information 2
  • 3. IDENTIFIERS / VARIABLES ▰ Identifiers may consists of: ❑ Letters (a-z, A-Z) ❑ Digits [0-9] ❑ Underscore “_” ▰ Identifiers ❑ Can begin only with a letter or an underscore ❑ Cannot be a C# keyword 3
  • 4. Variable (cont…) ▰ No other special characters are allowed including space ▰ Variable names are case sensitive ❑ A and a are different. ▰ Identifiers ❑ Should have a descriptive name ❑ Should be neither too long nor too short 4
  • 5. Declaring Variables ▰ When declaring a variable we: ❑ Specify its type ❑ Specify its name (called identifier) ❑ May give it an initial value ▰ The syntax is the following: ▰ example 5 <data_type> <identifier> [= <initialization>]; int height = 200;
  • 6. Variable (cont…) ▰ Variables are data that will keep on changing ▰ Declaration <<Data type>> <<variable name>>; int a; ▰ Definition <<varname>>=<<value>>; a=10; ▰ Usage <<varname>> a=a+1; //increments the value of a by 1 6
  • 7. Variable (cont…) ▰ Examples of correct identifiers: ▰ Examples of incorrect identifiers: 7 int New = 2; // Here N is capital int _2Pac; // This identifiers begins with _ string nosApab = “Hello”; // Unicode symbols used // The following is more appropriate: string greeting = “Hello”; int n= 100; // Undescriptive int numberOfClients = 100; // Descriptive // Overdescriptive identifier: int numberOfPrivateClientOfTheFirm = 100; int new; // new is a keyword int 2Pac; // cannot begin with a digit
  • 8. Declaring (cont…) ▰ Computers are machines that process data ❑ Data is stored in the computer memory in variables ❑ Variables have name, data type and value. ▰ Example of variable definition and assignment in C# int counter = 5; 8 Variable name Variable value Data type Assignment operator
  • 9. Declaring (cont…) ▰ Examples of variable declarations: int myAge = 25; ▰ The equal sign (=) is an assignment operator ▰ The assignment operator works from right to left ▰ An assignment made when a variable is declared is an initialization ▰ It is not necessary to initialize a variable during a declaration. ▰ For example int myAge; is a valid declaration 9
  • 10. Declaring (cont…) ▰ Examples of multiple variable declarations: ▻ int myAge = 25; int yourAge = 19; ▻ int myAge = 25, your Age = 19; ▰ Declarations of variables of the same type can be separated by commas. However, separate statements are used when declaring variables of different types ▻ int myAge, yourAge; double mySalary, yourSalary; 10
  • 11. Displaying Variable Values ▰ You can display variable values by using the variable name within a WriteLine() method call 11
  • 12. Displaying (cont…) ▰ Program that displays a string and a variable value 12
  • 13. THANKS! Any questions? You can find me at delfirome@gmail.com