Detailed_C_Programming_Notes
Detailed_C_Programming_Notes
C Character Set
The C character set includes:
- Letters: A-Z, a-z
- Digits: 0-9
- Special Symbols: +, -, *, /, %, &, etc.
- White Spaces: Spaces, tabs, newlines
- Other Characters: Escape sequences like \n, \t
Keywords:
- Reserved words in C with predefined meanings.
- Examples: int, float, return, if, else, while, for, break.
Data Types in C
C provides the following data types:
- int: Integer values (e.g., 10, -5)
- float: Floating-point numbers (e.g., 3.14, -0.002)
- double: Double precision floating-point numbers.
- char: Character data type (e.g., 'A', 'z').
Constants in C
Constants are fixed values that do not change during program execution. Types:
- Integer Constants: 10, 20, -5.
- Floating-point Constants: 3.14, -0.0002.
- Character Constants: 'A', 'b'.
- String Constants: "Hello", "C Programming".
Preprocessor Directives in C
Preprocessor directives are processed before compilation:
- #include: Includes header files.
- #define: Defines constants.
- #ifdef, #ifndef: Conditional compilation.
- #pragma: Special compiler instructions.
Symbolic Constants
Symbolic constants are defined using:
- #define: `#define PI 3.14`
- const keyword: `const int max = 100;`
Comments in C
Comments help in understanding code.
- Single-line comment: `// This is a comment`
- Multi-line comment: `/* This is a multi-line comment */`
sizeof Operator
The sizeof operator returns the memory size of a data type or variable.
- `sizeof(int)`: 4 bytes (on a 32-bit system)
- `sizeof(float)`: 4 bytes
- `sizeof(double)`: 8 bytes
- `sizeof(char)`: 1 byte