Variables

A variable is the name of the memory location. It is used to store information. Its value can be altered and reused several times. It is a way to represent memory location through symbols so that it can be easily identified. Variables are key building elements of the C programming language used to store and modify data in computer programs. A variable is a designated memory region that stores a specified data type value. Each variable has a unique identifier, its name, and a data type describing the type of data it may hold.

Here are some key points about variables:


Types of Variables

Code Example: Declaring and Using Variables


#include <stdio.h>
int globalVar = 10; // Global variable
int main() {
    int localVar = 5;     // Local variable
    static int staticVar; // Static variable (default value is 0)

    printf("Global Variable: %d\n", globalVar);
    printf("Local Variable: %d\n", localVar);
    printf("Static Variable: %d\n", staticVar);

    return 0;
}

Output

Global Variable: 10 Local Variable: 5 Static Variable: 0