Variable In C .

In this session i have discussed the variable in C .


Variable is a temprary place holder in memory that can hold the value .

Variable is a named location in memory that can hold the value .

Variable hold the value according their data types .


Variable Syntax :

    Data-Type Variable-Name 
    
    Data-Type Variable-Name =Value

    

C variable always defined with data type . You can assign the value at declaration time or later .

Variable Declaration :

    int x; // variable x declaration
   
    x=10;   // value assinged in x variable 
    ----------------------------------------------------------
    
    int y=20; // variable declared and assigned the value at same time 
    
    --------------------------------------------------------------------------- 

    int i , j  // Multiple line declaration of variable it is allowed in C
    
       

    ---------------------------------------------------------------------------

    int m=20;
    
    int n=m; // assign the value from m variable to n variable 
    

Rules for variable :

1-C is not allowed to give keywords as the name of variable .

2-C is not allowed Blank space in variable name .

3-C is allowed underscore(_) in variable name .

4-C variable is always start with alphabet not from number .

5-C is not allowed the special character like @ ,$ ,%,& etc in variable name .


Welcome to AndroidATPoint.

back image                     next image