1. variable

A variable is a named storage location in a program’s memory used to hold data. It acts like a labeled container that can store values of a specific data type, such as integers, floats, or strings.

Characteristics

Name: A unique identifier (e.g., age, totalPrice). Naming rules vary by language but generally:

Must start with a letter or underscore (_).

Can include letters, digits, and underscores.

Case-sensitive (e.g., Age ≠ age).

Cannot be a reserved keyword (e.g., class in Java).

Data Type: Specifies the kind of data the variable can hold (e.g., int, double, String).

Value: The data stored in the variable, which can change during program execution.

Scope: The region of the program where the variable is accessible (e.g., local, global).

Lifetime: The duration for which the variable exists in memory (e.g., during a function call for local variables).

Declaration and Initialization:

Declaration: Specifying the variable’s name and type (e.g., int age; in Java).

Initialization: Assigning an initial value (e.g., age = 25;).