C Programming: Constants, Variables, and Data Types
C Program Character Set
• Instructions formed using symbols and words according to syntax rules.
• Characters grouped into letters, digits, and special characters.
• White spaces ignored unless part of a string constant.
• Trigraph sequences used for unavailable characters on some keyboards.
C Program Tokens
• Smallest individual units in a C program.
• Six types of tokens used in C programming.
Integer Constants
• Sequence of digits.
• Types: Decimal, Octal, Hexadecimal.
Real Constants
• Represent quantities with fractional parts.
• Can be expressed in exponential notation.
Single Character Constants
• Single character enclosed in single quotes.
• Represented by ASCII values.
String Constants
• Sequence of characters in double quotes.
• No ASCII value.
Backslash Character Constants
• Special constants used in output functions.
• Known as escape sequences.
Variables
• Data names used to store values.
• Can change during program execution.
• Valid and invalid variable names.
Data Types
• Three classes: Primary, Derived, User-defined.
• Primary types: Integer, Character, Floating point, Double-precision, Void.
Declaring Variables
• Must be declared before use.
• Syntax: data_type v1, v2, vn;
• Local and global variables.
User-defined Type Declaration
• Allows defining an identifier for an existing data type.
• Syntax: typedef type identifier;
Declaration of Storage Class
• Variables have data type and storage class.
• Storage class specifies scope and lifetime.
Assigning Values to Variables
• Using = operator or scanf() function.
• Initialization during declaration.
Defining Symbolic Constants
• Use symbolic names for numeric values.
• Syntax: #define symbolic_name value
• Rules for defining and using symbolic constants.