Chap09 (ICS12)
Chap09 (ICS12)
12
(MS Access and C)
Copyright
Copyright @©ITITSeries
Series www.itseries.com.pk
An identifier is the name given to the variable, constant, function or label in the program.
Examples
printf scanf
2. User-defined Identifiers
A type of identifier that is defined by the programmer is known as user-defined identifier.
• The user-defined identifiers are used to store data and program results
Examples
my_name marks age
List of Keywords
All variables must be declared before they are used in the program Remember!
The compiler gives an error if
A program can have as many variables as needed an undeclared variable is used
in the program
The variable declaration provides information to the compiler about the variable
The compiler uses the declaration to determine how much memory is needed for each variable
Example – int variable requires 2 bytes and char variable requires 1 byte.
Once a variable is declared, its data type cannot be changed during program execution
Syntax Remember!
data_type variable_name; The value of the variable
can be changed during
program execution
data_type It indicates type of data that can be stored in variable
variable_name It refers to the memory location of the variable
• In separate statements
int length;
int width;
• In the same statement
int length, width;
3. String Constants
A collection of characters written in double quotations mark is called string or string constant.
May consist of any alphabetic characters, digits and special symbols
Examples
“Pakistan” “123” “99-Mall Road, Lahore”
An expression in which operands are of different data types is called mixed-type expression.
An expressions that has operands of both int and double is a mixed-type expression
variable = expression;
Examples
A = 100; A constant, variable or combination of
C = A + B; operands and arithmetical operators
X = C – D + 10;
variable op = expression;
possible to perform mathematical operation on character values
Example
Operator Example Equivalent to
+= A += 10 A = A + 10
-= A -= 10 A = A - 10
*= A *= 10 A = A * 10
/= A /= 10 A = A / 10
%= A %= 10 A = A % 10
Variable Declaration
Variable Declaration
Display operation
possible to perform mathematical the value on
of result
character values
Example:
Relational Operator
possible to perform mathematical operation on character values