C: Variables and Constants
Learn the basic methods of storing and managing data in memory.
1. Variables
A variable is a name assigned to a memory space where a value can be stored.
int age = 25; // Integer variable
float pi = 3.14f; // Floating-point variable
char grade = 'A'; // Character variable
2. Constants
Data that once defined, cannot have its value changed.
- const keyword:
const int MAX = 100; - #define macro:
#define PI 3.14159
📏 Naming Conventions
- Only alphanumeric characters and underscores (_) are allowed.
- Cannot start with a digit.
- Case-sensitive (
ageandAgeare different). - Reserved words (e.g.,
int,return) cannot be used as names.