Comprehensive notes for Chapter 9 Elements of C. Covers Identifiers, Keywords, Data Types, Variables, Constants, and Operators.
Definition: Names used to represent variables, constants, types, functions, and labels in the program.
Rules:
Types:
printf, scanf). Can be redefined (not recommended).marks, salary).Definition: Words with predefined meaning and purpose. Cannot be redefined. Written in lowercase.
List (32 Keywords): auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while.
Definition: Named memory location to store data. Value can change during execution.
Declaration: Specifying name and type. type variable_name; (e.g., int marks;).
Initialization: Assigning value at declaration. type variable = value; (e.g., int a = 10;).
Garbage Value: Meaningless data in uninitialized variable.
Integer Data Types:
int: 2 bytes. Range: -32768 to 32767.short: 2 bytes. Range: -32768 to 32767.unsigned int: 2 bytes. Range: 0 to 65535.long: 4 bytes. Range: -2,147,483,648 to 2,147,483,647.unsigned long: 4 bytes. Range: 0 to 4,294,967,295.Floating Point Data Types:
float: 4 bytes. Range: 10^-38 to 10^38. Precision: 6 decimal places.double: 8 bytes. Range: 10^-308 to 10^308. Precision: 15 decimal places.long double: 10 bytes. Range: 10^-4932 to 10^4932. Precision: 19 decimal places.Character Data Type:
char: 1 byte. Stores ASCII characters. Range: -128 to 127 (signed), 0 to 255 (unsigned).Definition: Quantity that cannot be changed during execution.
+, -, *, /, % (Modulus - remainder).==, !=, >, <, >=, <=. Returns True (1) or False (0).&& (AND), || (OR), ! (NOT).= assign value. Compound: +=, -=, *=, /=, %= (e.g., a+=10 same as a=a+10).++ increases by 1, -- decreases by 1.++x (Change then use).x++ (Use then change).Order of evaluation in expression:
()!, ++, --*, /, %+, -<, <=, >, >===, !=&&||=, +=, etc.