Professional Documents
Culture Documents
Coimbatore-35.
An Autonomous Institution
Accredited by NBA – AICTE and Accredited by NAAC – UGC with ‘A+’ Grade
Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai
UNIT – I INTRODUCTION
Mr.M.Karthick
Assistant Professor
Department of Computer Science and Engineering
Variables
• A variable name can only have alphabets, numbers and the underscore _.
• A variable name cannot be a keyword. For example, int is a keyword that is used to denote
integers.
• A variable name can start with an underscore. However, it's not considered a good practice.
Based on the location of variable declaration, variables are classified into two types. They are
as follows.
• Local Variables
• Global Variables
• When we do not want others to override existing variable values, we can use
the const keyword
• This will declare the variable as "constant", which means unchangeable and read-only
Example 1:
const int minutesPerHour = 60;
const float PI = 3.14;
Example 2:
const int myNum = 15; // myNum will always be 15
myNum = 10; / / error: assignment of read-only variable 'myNum'