Variables
• Variables are simply names used to refer to some
location in memory – a location that holds a value with
which we are working.
• Variables are placeholder for a value.
• Variable can hold different value at different instance.
Rules for naming variables:
• All variable names must begin with a letter of the alphabet
or an underscore( _ ). ...
• After the first initial letter, variable names can also contain
letters and numbers. ...
• Uppercase characters are distinct from lowercase
characters.
• We cannot use a C keyword (reserved word) as a variable
name.
Variable Initialization
• Initialization is the assignment of an initial
value for a data or variable.
• Initialization is performed depends on
programming language, as well as data type,
storage class, etc.
Example variable:
Sum, Avg, avg, _date,S_No etc.
Constants/Literals
• A constant is a value (or an identifier) whose
value cannot be altered in a program. For
example: 1, 2.5, 'c' etc.
• Here, 1, 2.5 and 'c'are literal constants. Why? You
cannot assign different values to these terms.
• You can also create non-modifiable variables in C
programming. For example:
• const double PI = 3.14; Notice, we have added
keyword const.
Constant Example
• Here, PI is a symbolic constant. It's actually a
variable however, it's value cannot be
changed.
const double PI = 3.14;
PI = 2.9; //Error
• Here, PI is a symbolic constant. It's actually a
variable however, it's value cannot be
changed.
• const double PI = 3.14; PI = 2.9; //Error
Types of C Constant
• Integer constants
• Real or Floating point constants
• Octal & Hexadecimal constants
• Character constants
• String constants
• Backslash character constants
Data types
• C data types are defined as the data storage format that a
variable can store a data to perform a specific operation.
• Data types are used to define a variable before to use in a
program.
• Size of variable, constant and array are determined by data
types.
• Types of Data types,