Programming in C: Constants, Variables, and Data Types
Programming in C: Constants, Variables, and Data Types
Programming in C: Constants, Variables, and Data Types
Part II
Constants, Variables, and Data types
The C Character Set
C uses:
• Uppercase letters (A→Z)
• Lowercase letters (a→z)
• Digits (0→9)
• Some special symbols (+, *, %, &, #, {, }, …etc).
Variables and Constants
• Variables and constants are named memory
locations in which data of a certain type can
be stored.
• Constants refer to data that remains
unchanged throughout the program
execution.
• Variables store data that may vary during
program exe
• Variables and constants must be declared
before they can be used in a program.
Identifiers and Keywords
1. Identifiers
• Identifiers are names given to various program
elements such as variables, functions, and arrays.
• Rules for naming:
– Only alphabets, digits, and underscores are allowed.
– An identifier must start with a letter or an underscore,
and may be followed by any combination of
characters, underscores, or the digits 0-9.
– The name cannot start with a digit.
– Uppercase and lowercase letters are treated as
different.
– Optional: always choose a meaningful names for
identifiers in order to make programs easier to read.
Identifiers and Keywords
1. Identifiers
• Examples of valid identifiers:
x, y21, sum, sum_1, taxe_rate, _temperture.
1 byte (8 bits)
1 byte (8 bits)
int main( ) {
int a,b;
const float c=6.022
float d;
}