Variables in C

In C programming, variables are named storage locations in memory used to hold data that can change during the execution of a program. Each variable is associated with a specific data type, which determines the kind of data it can store, such as integers, floating-point numbers, or characters.

Types of Variables:


 Basic Data Types:

        int: For integers (e.g., int age = 30;).
        float: For single-precision floating-point values (e.g., float salary = 50000.0;).
        double: For double-precision floating-point values.
        char: For single characters (e.g., char initial = 'A';).

Derived Data Types:

        Arrays: Collections of variables of the same type (e.g., int arr[10];).
        Pointers: Variables that store memory addresses (e.g., int *ptr;).
        Structures: User-defined data types that group different data types together.

Declaration and Initialization:

Variables must be declared before use, specifying their type. They can be initialized at declaration or later. For example, int age = 25; initializes the variable age with a value.




  • To Share this Link, Choose your plateform


Our Other Tutorials